how looks the lisp `car` function in asm?
Posted: Mon Jul 05, 2004 12:57 pm
hi,
i`m new in lisp and i`m wondering (is my english correct?.. it doesn`t matter ::) ) how the car function looks like if its compiled --> assembler code, i made a example.please give me your comments.
d11in
example:
it`s a 32-bit assembler routine, the input argument (eax) shoul`d be a list (cons cell) and the output argument is the car value (eax) which can be an atom or a list. the three `highest significant` bits are used for typing and garbage collection, maybe. we work in a single-address space, unsegmented protected mode --> 32-bit flat pmode....
i`m new in lisp and i`m wondering (is my english correct?.. it doesn`t matter ::) ) how the car function looks like if its compiled --> assembler code, i made a example.please give me your comments.
d11in
example:
it`s a 32-bit assembler routine, the input argument (eax) shoul`d be a list (cons cell) and the output argument is the car value (eax) which can be an atom or a list. the three `highest significant` bits are used for typing and garbage collection, maybe. we work in a single-address space, unsegmented protected mode --> 32-bit flat pmode....
Code: Select all
f-car: push ebp ; enter stack frame
mov ebp,esp
mov ebx,eax ; store argument in ebx too
and eax,0xE0000000 ; check if arg a list
jz f-car-work
f-car-error: ??? ; illegal CAR argument
pop ebp
ret
f-car-work: and ebx,0x1fffffff ; get car-value
mov eax,[ebx]
pop ebp ; leave stack frame
ret