mirror of
https://github.com/samsonjs/sectorlisp.git
synced 2026-03-25 09:05:48 +00:00
Make intern function more readable
This commit is contained in:
parent
7f55a4be0a
commit
17bd5be818
2 changed files with 26 additions and 31 deletions
6
lisp.c
6
lisp.c
|
|
@ -111,12 +111,8 @@ GetObject(c) {
|
||||||
return Intern();
|
return Intern();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadObject() {
|
|
||||||
return GetObject(GetToken());
|
|
||||||
}
|
|
||||||
|
|
||||||
Read() {
|
Read() {
|
||||||
return ReadObject();
|
return GetObject(GetToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAtom(x) {
|
PrintAtom(x) {
|
||||||
|
|
|
||||||
51
sectorlisp.S
51
sectorlisp.S
|
|
@ -68,7 +68,7 @@ GetToken: # GetToken():al, dl is g_look
|
||||||
jbe 3f
|
jbe 3f
|
||||||
cmp $')',%dl # dl = g_look
|
cmp $')',%dl # dl = g_look
|
||||||
ja 1b
|
ja 1b
|
||||||
3: movb %bh,(%di) # bh is zero
|
3: mov %bh,(%di) # bh is zero
|
||||||
xchg %si,%ax
|
xchg %si,%ax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
@ -86,6 +86,7 @@ GetToken: # GetToken():al, dl is g_look
|
||||||
call .PutObject
|
call .PutObject
|
||||||
4: mov $')',%al
|
4: mov $')',%al
|
||||||
jmp PutChar
|
jmp PutChar
|
||||||
|
|
||||||
.PutObject: # .PutObject(c:al,x:si)
|
.PutObject: # .PutObject(c:al,x:si)
|
||||||
.PrintString: # nul-terminated in si
|
.PrintString: # nul-terminated in si
|
||||||
call PutChar # preserves si
|
call PutChar # preserves si
|
||||||
|
|
@ -99,32 +100,30 @@ PrintObject: # PrintObject(x:si)
|
||||||
ret
|
ret
|
||||||
|
|
||||||
GetObject: # called just after GetToken
|
GetObject: # called just after GetToken
|
||||||
cmpb $'(',%al
|
cmp $'(',%al
|
||||||
je GetList
|
je GetList
|
||||||
.Intern:
|
# jmp Intern
|
||||||
mov %cx,%si
|
|
||||||
|
Intern: push %cx # Intern(cx,di): ax
|
||||||
|
mov %di,%bp
|
||||||
|
sub %cx,%bp
|
||||||
|
inc %bp
|
||||||
xor %di,%di
|
xor %di,%di
|
||||||
xor %al,%al
|
1: pop %si
|
||||||
0: push %di # save 1
|
push %si
|
||||||
1: cmpsb
|
mov %bp,%cx
|
||||||
jne 2f
|
mov %di,%ax
|
||||||
dec %di
|
cmp %bh,(%di)
|
||||||
scasb
|
je 2f
|
||||||
jne 1b
|
rep cmpsb # memcmp(di,si,cx)
|
||||||
jmp 5f
|
je 9f
|
||||||
2: pop %bp # drop 1
|
not %cx
|
||||||
mov %cx,%si
|
xor %ax,%ax
|
||||||
3: scasb
|
repne scasb # memchr(di,al,cx)
|
||||||
jne 3b
|
jmp 1b
|
||||||
cmp (%di),%al
|
2: rep movsb # memcpy(di,si,cx)
|
||||||
jne 0b
|
9: pop %cx
|
||||||
push %di # StpCpy
|
ret
|
||||||
4: movsb
|
|
||||||
dec %di
|
|
||||||
scasb
|
|
||||||
jnz 4b
|
|
||||||
5: pop %ax # restore 1
|
|
||||||
.ret: ret
|
|
||||||
|
|
||||||
GetChar:xor %ax,%ax # GetChar→al:dl
|
GetChar:xor %ax,%ax # GetChar→al:dl
|
||||||
int $0x16 # get keystroke
|
int $0x16 # get keystroke
|
||||||
|
|
@ -185,7 +184,7 @@ Gc: cmp %dx,%di # Gc(x:di,A:dx,B:si):ax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
GetList:call GetToken
|
GetList:call GetToken
|
||||||
cmpb $')',%al
|
cmp $')',%al
|
||||||
je .retF
|
je .retF
|
||||||
call GetObject
|
call GetObject
|
||||||
push %ax # popped by xCons
|
push %ax # popped by xCons
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue