From: rusty craine
Subject: Lisp internal gurus - machine-coded routines
Date: 
Message-ID: <72o49c$h5h$1@excalibur.flash.net>
muLisp has great documentation on running machine-coded routines.  The basic
are code up your routine plus several internal house keeping chores,
assemble it, allocate enough space in the code segment, call BINARY-LOAD to
load the routine, call PUTD to the the symbol's function definiton cell to
the routine.  Routines that cons or genrates numbers may call GC so an
effort must be to take care of the variable stack if mulisp is to use a
value from the routine.  When the routines leaves restore DX and the four
segement registers and your own your way.

I have written lots of these routines and understand MASM and assembler
well.  Now here is what I would like to do.  MuLisp is not at common lisp
but in a file _common.lsp_  software house has written alot of common lisp
in lisp.  The function that is not there at all is FORMAT and SETF is
written in mulisp.  I would like to write assembler routines for these two
functions.  The reason I would like to write a SETF routine is that as a
lisp in lisp function it is a bit slow for some of the realtime stuff I have
asked it to do.

I have got a start on FORMAT using the specs from Harlequin's Hyperspecs.
So far FORMAT is not too bad since in Mulisp as the arugments to a function
are evaulated, the addresses of the resulting data objects are pushed on to
the variable stack.  The BP register is the varible stack pointer.  Then the
machine-coded function is called with the arugments stored above the top of
the varible stack.  On entry to the routine, CX contains two time the number
of acutal arugments that were in the call to the function.  This at least so
far makes FORMAT fairly transparent unless I am missing something.   Flush
with a little success with FORMAT I set down with my notebook to map out how
I thought I'd write SETF.  Hmmmmmm after trashing a dozen or so pages it is
clear I don't have a clue.  Alas the problem is all to fundemental....I
guess I really only understand SETF extrenally, used it alot never really
thought of what was happening under the hood with segements, stack,
registers etc.  As I commented earlier I've got SETF written in muLisp so
I'll start going trough that code to see if the little light comes on.

I guess I'm writting a book???? sorry.  The question is.....can any of you
under the hood coders  point me  direction that would make the flight a
little shorter.

Fling on instruments but got a full tank of gas!
Rusty

--
Email address  is ········@flash.net.  Under some situation the "a" and the
"l" in flash are reversed in the header.
Rusty Craine

From: Barry Margolin
Subject: Re: Lisp internal gurus - machine-coded routines
Date: 
Message-ID: <jCO32.3$zQ5.97527@burlma1-snr1.gtei.net>
In article <············@excalibur.flash.net>,
rusty craine <········@flash.net> wrote:
>The reason I would like to write a SETF routine is that as a
>lisp in lisp function it is a bit slow for some of the realtime stuff I have
>asked it to do.

This doesn't make any sense.  SETF is a macro, so it's gone by the time you
run the program.  How can the language it's written in affect performance?

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.
From: Marco Antoniotti
Subject: Re: Lisp internal gurus - machine-coded routines
Date: 
Message-ID: <lwn25sxac5.fsf@copernico.parades.rm.cnr.it>
I do not understand why you insist on working on muLisp.  Are there
really cost considerations that keep you from porting the beast to one
of the commercial system or to one of the non-commercial ones?

-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - (0)6 - 68 10 03 16, fax. +39 - (0)6 - 68 80 79 26
http://www.parades.rm.cnr.it
From: rusty craine
Subject: Re: Lisp internal gurus - machine-coded routines
Date: 
Message-ID: <72p3rq$n9i$1@excalibur.flash.net>
Marco Antoniotti wrote in message ...
>
>I do not understand why you insist on working on muLisp.  Are there
>really cost considerations that keep you from porting the beast to one
>of the commercial system or to one of the non-commercial ones?
>
We are in the process of selecting commercial systems and a new OS.  That
means porting 10+ years of _stuff_.  A most of the code is indeed wrapped
around machine-coded rountines that drive async communication devices,
communicates with IRMA's TSR automating mainframe data transfers (one of
those is pay roll, not one you want to screw up), geeez Macro they just go
on and on.

Frankly there are now commercial products to do all the task we used muLisp
for, none of them are in or about lisp.  I would guess in the next three
years there will not be a line of lisp running anywhere in our enterprise.
Sad for me.

All that said the real answer to your question is I like it.  muLisp and I
have been good friends for a decade.  MuLisp is kinda like my old welch
corgi, can't work sheep any more, mostly blind, arthritic..but still my dog.

The good news is I'm three years for retirement.
Rusty
>--
>Marco Antoniotti ===========================================
>PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
>tel. +39 - (0)6 - 68 10 03 16, fax. +39 - (0)6 - 68 80 79 26
>http://www.parades.rm.cnr.it
From: rusty craine
Subject: Re: Lisp internal gurus - machine-coded routines
Date: 
Message-ID: <72p27k$jga$1@excalibur.flash.net>
Barry Margolin wrote in message ...
>In article <············@excalibur.flash.net>,
>rusty craine <········@flash.net> wrote:
>>The reason I would like to write a SETF routine is that as a
>>lisp in lisp function it is a bit slow for some of the realtime stuff I
have
>>asked it to do.
>
>This doesn't make any sense.  SETF is a macro, so it's gone by the time you
>run the program.  How can the language it's written in affect performance?
>
Yes of course you are right.  What I need to write is SETF-AUX and
MAKE-SET-FORM.  I not am sure that is going to be any easier.    It is kinda
funny; never used SETF till I started reading this news group, now I don't
think I can get along without.  I think it has to do with my quest to learn
to write lisp-like lisp.  The lack of SETF is easy to work around...and the
alternate code runs faster.  T'is just one of those little exercises our
mind comes up with that might not have been a good idea. hmmm still it is a
challenge.......

;;;;;------------------------------------------------------------------
;; AS SUPPLIED WITH MULISP IN COMMON.LSP
;;;;-------------------------------------------------------------------
(DEFMACRO SETF LST
; If PLACE is a valid place form, (SETF PLACE FORM) stores the result of
; evaluating FORM in PLACE.
  ((NULL LST) NIL)
  ((NULL (CDDR LST))
    ((ATOM (CAR LST))
      (CONS 'SETQ LST) )
    (MAKE-SET-FORM (CAR LST) (CADR LST)) )
  (CONS 'PROGN (SETF-AUX LST)) )

(DEFUN SETF-AUX (LST
; Returns a list of SETF forms.
    TMP)
  ((NULL LST) NIL)
  ((ATOM (CAR LST))
    ((AND (SETQ TMP (SETF-AUX (CDDR LST))) (EQ (CAAR TMP) 'SETQ))
      (CONS (LIST* 'SETQ (CAR LST) (CADR LST) (CDAR TMP)) (CDR TMP)) )
    (CONS (LIST 'SETQ (CAR LST) (CADR LST)) TMP) )
  (CONS (MAKE-SET-FORM (CAR LST) (CADR LST)) (SETF-AUX (CDDR LST))) )

(DEFUN MAKE-SET-FORM (PLACE VALUE)
; Returns a form that changes the value stored at PLACE to VALUE.
  ((ATOM PLACE)
    (LIST 'SETQ PLACE VALUE) )
  ((EQ (CAR PLACE) 'CAR)
    (LIST 'CAR (LIST 'RPLACA (CADR PLACE) VALUE)) )
  ((OR (EQ (CAR PLACE) 'CDR) (EQ (CAR PLACE) 'REST))
    (LIST 'CDR (LIST 'RPLACD (CADR PLACE) VALUE)) )
  ((EQ (CAR PLACE) 'NTH)
    (LIST 'CAR (LIST 'RPLACA (CONS 'NTHCDR (CDR PLACE)) VALUE)) )
  ((EQ (CAR PLACE) 'GET)
    (LIST 'PUT (CADR PLACE) (CADDR PLACE) VALUE) )
  ((EQ (CAR PLACE) 'SYMBOL-FUNCTION)
    (LIST 'PUTD (CADR PLACE) VALUE) )
  ((GET (CAR PLACE) 'CAR)  (LIST 'CAR
      (LIST 'RPLACA (LIST (GET (CAR PLACE) 'CAR) (CADR PLACE)) VALUE)) )
  ((GET (CAR PLACE) 'CDR)  (LIST 'CDR
      (LIST 'RPLACD (LIST (GET (CAR PLACE) 'CDR) (CADR PLACE)) VALUE)) )
  ((GET (CAR PLACE) 'NTH)
    (LIST 'CAR (LIST 'RPLACA
                     (LIST 'NTHCDR (GET (CAR PLACE) 'NTH) (CADR PLACE))
                     VALUE)) )
  ((MACRO-P (CAR PLACE))
    (MAKE-SET-FORM (MACROEXPAND PLACE) VALUE) )
  (BREAK (LIST 'SETF PLACE VALUE) "Invalid Place Form") )

>--
>Barry Margolin, ······@bbnplanet.com
>GTE Internetworking, Powered by BBN, Burlington, MA
>*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
>Don't bother cc'ing followups to me.