mirror of
https://github.com/samsonjs/sectorlisp.git
synced 2026-04-27 14:57:41 +00:00
Add READ and PRINT
This commit is contained in:
parent
194181a709
commit
ef4f143680
1 changed files with 23 additions and 6 deletions
29
sectorlisp.S
29
sectorlisp.S
|
|
@ -28,6 +28,8 @@ _start: .asciz "NIL" # dec %si ; dec %cx ; dec %sp
|
||||||
kT: .asciz "T" # add %dl,(%si) boot A:\ DL=0
|
kT: .asciz "T" # add %dl,(%si) boot A:\ DL=0
|
||||||
start: ljmp $0x7c00>>4,$begin # cs = 0x7c00 is boot address
|
start: ljmp $0x7c00>>4,$begin # cs = 0x7c00 is boot address
|
||||||
.asciz "" # interned strings
|
.asciz "" # interned strings
|
||||||
|
kRead: .asciz "READ" # builtin for eval
|
||||||
|
kPrint: .asciz "PRINT" # builtin for eval
|
||||||
kQuote: .asciz "QUOTE" # builtin for eval
|
kQuote: .asciz "QUOTE" # builtin for eval
|
||||||
kCond: .asciz "COND" # builtin for eval
|
kCond: .asciz "COND" # builtin for eval
|
||||||
kCar: .asciz "CAR" # builtin to apply
|
kCar: .asciz "CAR" # builtin to apply
|
||||||
|
|
@ -52,12 +54,9 @@ begin: mov $0x8000,%sp # uses higher address as stack
|
||||||
mov $2,%bx
|
mov $2,%bx
|
||||||
main: mov %sp,%cx
|
main: mov %sp,%cx
|
||||||
mov $'\r',%al
|
mov $'\r',%al
|
||||||
call PutChar # Call first to initialize %dx
|
call PutChar
|
||||||
call GetToken
|
call Read
|
||||||
call GetObject
|
call EvalPrint
|
||||||
call Eval
|
|
||||||
xchg %ax,%si
|
|
||||||
call PrintObject
|
|
||||||
jmp main
|
jmp main
|
||||||
|
|
||||||
GetToken: # GetToken():al, dl is g_look
|
GetToken: # GetToken():al, dl is g_look
|
||||||
|
|
@ -105,6 +104,8 @@ PrintObject: # PrintObject(x:si)
|
||||||
jnz .PrintString # -> ret
|
jnz .PrintString # -> ret
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Read: call GetChar
|
||||||
|
call GetToken
|
||||||
GetObject: # called just after GetToken
|
GetObject: # called just after GetToken
|
||||||
cmp $'(',%al
|
cmp $'(',%al
|
||||||
je GetList
|
je GetList
|
||||||
|
|
@ -143,6 +144,18 @@ PutChar:mov $0x0e,%ah # prints CP-437
|
||||||
.RetDx: xchg %dx,%ax
|
.RetDx: xchg %dx,%ax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Print: mov (%si),%si # si = Cdr(e)
|
||||||
|
mov (%si),%ax # ax = Car(Cdr(e))
|
||||||
|
EvalPrint:
|
||||||
|
call Eval
|
||||||
|
push %ax
|
||||||
|
push %dx
|
||||||
|
xchg %ax,%si
|
||||||
|
call PrintObject
|
||||||
|
pop %dx
|
||||||
|
pop %ax
|
||||||
|
ret
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Evlis: test %di,%di # Evlis(m:di,a:dx):ax
|
Evlis: test %di,%di # Evlis(m:di,a:dx):ax
|
||||||
|
|
@ -258,6 +271,10 @@ Eval: test %ax,%ax # Eval(e:ax,a:dx):ax
|
||||||
jns Assoc # lookup val if atom
|
jns Assoc # lookup val if atom
|
||||||
xchg %ax,%si # di = e
|
xchg %ax,%si # di = e
|
||||||
lodsw # ax = Car(e)
|
lodsw # ax = Car(e)
|
||||||
|
cmp $kRead,%ax
|
||||||
|
je Read
|
||||||
|
cmp $kPrint,%ax
|
||||||
|
je Print
|
||||||
cmp $kQuote,%ax # maybe CONS
|
cmp $kQuote,%ax # maybe CONS
|
||||||
mov (%si),%di # di = Cdr(e)
|
mov (%si),%di # di = Cdr(e)
|
||||||
je Car
|
je Car
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue