mirror of
https://github.com/samsonjs/sectorlisp.git
synced 2026-04-27 14:57:41 +00:00
shave some bytes
This commit is contained in:
parent
05d2bcbfd9
commit
a469910340
1 changed files with 42 additions and 42 deletions
84
sectorlisp.S
84
sectorlisp.S
|
|
@ -97,7 +97,6 @@ GetObject: # called just after GetToken
|
||||||
je GetList
|
je GetList
|
||||||
mov $g_token,%si
|
mov $g_token,%si
|
||||||
.Intern:
|
.Intern:
|
||||||
mov %si,%bx # save s
|
|
||||||
mov $g_str,%di
|
mov $g_str,%di
|
||||||
xor %al,%al
|
xor %al,%al
|
||||||
0: mov $-1,%cl
|
0: mov $-1,%cl
|
||||||
|
|
@ -108,7 +107,7 @@ GetObject: # called just after GetToken
|
||||||
jne 1b
|
jne 1b
|
||||||
jmp 4f
|
jmp 4f
|
||||||
2: pop %si # drop 1
|
2: pop %si # drop 1
|
||||||
mov %bx,%si # restore s
|
mov $g_token,%si
|
||||||
repne scasb
|
repne scasb
|
||||||
cmp (%di),%al
|
cmp (%di),%al
|
||||||
jne 0b
|
jne 0b
|
||||||
|
|
@ -122,6 +121,11 @@ GetObject: # called just after GetToken
|
||||||
adc %ax,%ax # ax = 2 * ax + carry
|
adc %ax,%ax # ax = 2 * ax + carry
|
||||||
.ret: ret
|
.ret: ret
|
||||||
|
|
||||||
|
.PutObject: # .PutObject(c:al,x:di)
|
||||||
|
call PutChar # preserves di
|
||||||
|
xchg %di,%ax
|
||||||
|
# jmp PrintObject
|
||||||
|
|
||||||
PrintObject: # PrintObject(x:ax)
|
PrintObject: # PrintObject(x:ax)
|
||||||
test $1,%al
|
test $1,%al
|
||||||
xchg %ax,%di
|
xchg %ax,%di
|
||||||
|
|
@ -151,10 +155,6 @@ PrintObject: # PrintObject(x:ax)
|
||||||
call .PutObject
|
call .PutObject
|
||||||
4: mov $')',%al
|
4: mov $')',%al
|
||||||
jmp PutChar
|
jmp PutChar
|
||||||
.PutObject: # .PutObject(c:al,x:di)
|
|
||||||
call PutChar # preserves di
|
|
||||||
xchg %di,%ax
|
|
||||||
jmp PrintObject
|
|
||||||
|
|
||||||
GetChar:
|
GetChar:
|
||||||
xor %ax,%ax # get keystroke
|
xor %ax,%ax # get keystroke
|
||||||
|
|
@ -180,9 +180,7 @@ GetList:call GetToken
|
||||||
call GetObject
|
call GetObject
|
||||||
push %ax # save 1
|
push %ax # save 1
|
||||||
call GetList
|
call GetList
|
||||||
xchg %ax,%si
|
jmp xCons
|
||||||
pop %di # restore 1
|
|
||||||
jmp Cons
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
@ -196,7 +194,8 @@ Evlis: cmp $NIL,%di # Evlis(m:di,a:dx):ax
|
||||||
pop %di # restore 1
|
pop %di # restore 1
|
||||||
push %ax # save 2
|
push %ax # save 2
|
||||||
call Evlis
|
call Evlis
|
||||||
xchg %ax,%si
|
|
||||||
|
xCons: xchg %ax,%si
|
||||||
pop %di # restore 2
|
pop %di # restore 2
|
||||||
# jmp Cons
|
# jmp Cons
|
||||||
Cons: xchg %di,%ax
|
Cons: xchg %di,%ax
|
||||||
|
|
@ -228,6 +227,36 @@ Pairlis:cmp $NIL,%di # Pairlis(x:di,y:si,a:dx):ax
|
||||||
1: xchg %dx,%ax
|
1: xchg %dx,%ax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Evcon: push %di # save c
|
||||||
|
mov (%di),%di # di = Car(c)
|
||||||
|
mov (%di),%ax # ax = Caar(c)
|
||||||
|
push %dx # save a
|
||||||
|
call Eval
|
||||||
|
pop %dx # restore a
|
||||||
|
pop %di # restore c
|
||||||
|
cmp $NIL,%ax
|
||||||
|
jne 2f
|
||||||
|
mov 2(%di),%di # di = Cdr(c)
|
||||||
|
jmp Evcon
|
||||||
|
2: mov (%di),%di # di = Car(c)
|
||||||
|
.EvCadr:call Cadr # ax = Cadar(c)
|
||||||
|
# jmp Eval
|
||||||
|
|
||||||
|
Eval: test $1,%al # Eval(e:ax,a:dx):ax
|
||||||
|
jnz Assoc
|
||||||
|
xchg %ax,%di # di = e
|
||||||
|
mov (%di),%ax # ax = Car(e)
|
||||||
|
cmp $ATOM_QUOTE,%ax # maybe CONS
|
||||||
|
je Cadr
|
||||||
|
mov 2(%di),%di # di = Cdr(e)
|
||||||
|
cmp $ATOM_COND,%ax
|
||||||
|
je Evcon
|
||||||
|
.Ldflt2:push %ax # save 2
|
||||||
|
call Evlis # preserves dx
|
||||||
|
xchg %ax,%si
|
||||||
|
pop %ax # restore 2
|
||||||
|
# jmp Apply
|
||||||
|
|
||||||
Apply: test $1,%al # Apply(fn:ax,x:si:a:dx):ax
|
Apply: test $1,%al # Apply(fn:ax,x:si:a:dx):ax
|
||||||
jnz .switch
|
jnz .switch
|
||||||
xchg %ax,%di # di = fn
|
xchg %ax,%di # di = fn
|
||||||
|
|
@ -270,39 +299,12 @@ Apply: test $1,%al # Apply(fn:ax,x:si:a:dx):ax
|
||||||
pop %si # restore x
|
pop %si # restore x
|
||||||
jmp Apply
|
jmp Apply
|
||||||
|
|
||||||
Eval: test $1,%al # Eval(e:ax,a:dx):ax
|
|
||||||
jnz Assoc
|
|
||||||
xchg %ax,%di # di = e
|
|
||||||
mov (%di),%ax # ax = Car(e)
|
|
||||||
cmp $ATOM_QUOTE,%ax # maybe CONS
|
|
||||||
je Cadr
|
|
||||||
mov 2(%di),%di # di = Cdr(e)
|
|
||||||
cmp $ATOM_COND,%ax
|
|
||||||
je Evcon
|
|
||||||
.Ldflt2:push %ax # save 2
|
|
||||||
call Evlis # preserves dx
|
|
||||||
xchg %ax,%si
|
|
||||||
pop %ax # restore 2
|
|
||||||
jmp Apply
|
|
||||||
|
|
||||||
Cadr: mov 2(%di),%di # contents of decrement register
|
Cadr: mov 2(%di),%di # contents of decrement register
|
||||||
mov (%di),%ax # contents of address register
|
mov (%di),%ax # contents of address register
|
||||||
ret
|
ret
|
||||||
|
|
||||||
Evcon: push %di # save c
|
assoc1: mov 2(%si),%dx # dx = Cdr(y)
|
||||||
mov (%di),%di # di = Car(c)
|
# jmp Assoc
|
||||||
mov (%di),%ax # ax = Caar(c)
|
|
||||||
push %dx # save a
|
|
||||||
call Eval
|
|
||||||
pop %dx # restore a
|
|
||||||
pop %di # restore c
|
|
||||||
cmp $NIL,%ax
|
|
||||||
jne 2f
|
|
||||||
mov 2(%di),%di # di = Cdr(c)
|
|
||||||
jmp Evcon
|
|
||||||
2: mov (%di),%di # di = Car(c)
|
|
||||||
.EvCadr:call Cadr # ax = Cadar(c)
|
|
||||||
jmp Eval
|
|
||||||
|
|
||||||
Assoc: cmp $NIL,%dx # Assoc(x:ax,y:dx):ax
|
Assoc: cmp $NIL,%dx # Assoc(x:ax,y:dx):ax
|
||||||
mov %dx,%si
|
mov %dx,%si
|
||||||
|
|
@ -310,11 +312,9 @@ Assoc: cmp $NIL,%dx # Assoc(x:ax,y:dx):ax
|
||||||
mov (%si),%bx # bx = Car(y)
|
mov (%si),%bx # bx = Car(y)
|
||||||
mov (%bx),%cx # cx = Caar(y)
|
mov (%bx),%cx # cx = Caar(y)
|
||||||
cmp %cx,%ax
|
cmp %cx,%ax
|
||||||
jne 1f
|
jne assoc1
|
||||||
mov 2(%bx),%ax # ax = Cdar(y)
|
mov 2(%bx),%ax # ax = Cdar(y)
|
||||||
ret
|
ret
|
||||||
1: mov 2(%si),%dx # dx = Cdr(y)
|
|
||||||
jmp Assoc
|
|
||||||
|
|
||||||
.type .sig,@object;
|
.type .sig,@object;
|
||||||
.sig:
|
.sig:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue