mirror of
https://github.com/samsonjs/sectorlisp.git
synced 2026-04-27 14:57:41 +00:00
smaller Intern function
This commit is contained in:
parent
2c1ddc26da
commit
333c5efba4
2 changed files with 36 additions and 42 deletions
68
sectorlisp.S
68
sectorlisp.S
|
|
@ -18,9 +18,9 @@
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
|
||||||
// @fileoverview lisp.c built for real mode with manual tuning
|
// @fileoverview lisp.c built for real mode with manual tuning
|
||||||
// binary footprint is approximately 960 bytes, about 40 bytes
|
// binary footprint is approximately 824 bytes, about 40 bytes
|
||||||
// of it is overhead needed to load the second 512-byte sector
|
// of it is overhead needed to load the second 512-byte sector
|
||||||
// so if we can find a way to reduce the code size another 400
|
// so if we can find a way to reduce the code size another 300
|
||||||
// bytes we can bootstrap the metacircular evaluator in an mbr
|
// bytes we can bootstrap the metacircular evaluator in an mbr
|
||||||
|
|
||||||
#define NIL 0
|
#define NIL 0
|
||||||
|
|
@ -139,37 +139,33 @@ GetObject:
|
||||||
|
|
||||||
Intern: mov %di,%bx
|
Intern: mov %di,%bx
|
||||||
mov $STR,%si
|
mov $STR,%si
|
||||||
0: lodsb
|
0: mov %bx,%di
|
||||||
test %al,%al
|
push %si
|
||||||
je 4f
|
lodsb
|
||||||
xor %dx,%dx
|
|
||||||
1: mov %dx,%di
|
|
||||||
mov (%bx,%di),%cl
|
|
||||||
cmp %cl,%al
|
|
||||||
jne 3f
|
|
||||||
inc %dx
|
|
||||||
test %al,%al
|
test %al,%al
|
||||||
jne 2f
|
jne 2f
|
||||||
sub %di,%si
|
pop %di
|
||||||
lea -STR-1(%si),%ax
|
push %di
|
||||||
jmp 6f
|
mov %bx,%si
|
||||||
2: lodsb
|
4: lodsb
|
||||||
jmp 1b
|
stosb
|
||||||
|
test %al,%al
|
||||||
|
jnz 4b
|
||||||
|
6: pop %ax
|
||||||
|
sub $STR,%ax
|
||||||
|
shl %ax
|
||||||
|
ret
|
||||||
|
1: lodsb
|
||||||
|
2: scasb
|
||||||
|
jne 5f
|
||||||
|
test %al,%al
|
||||||
|
jne 1b
|
||||||
|
jmp 6b
|
||||||
|
5: pop %di
|
||||||
3: test %al,%al
|
3: test %al,%al
|
||||||
jz 0b
|
jz 0b
|
||||||
lodsb
|
lodsb
|
||||||
jmp 3b
|
jmp 3b
|
||||||
4: lea -1(%si),%di
|
|
||||||
push %di
|
|
||||||
mov %bx,%si
|
|
||||||
0: lodsb
|
|
||||||
stosb
|
|
||||||
test %al,%al
|
|
||||||
jnz 0b
|
|
||||||
pop %ax
|
|
||||||
sub $STR,%ax
|
|
||||||
6: shl %ax
|
|
||||||
ret
|
|
||||||
|
|
||||||
GetList:call GetToken
|
GetList:call GetToken
|
||||||
mov q.token,%al
|
mov q.token,%al
|
||||||
|
|
@ -250,6 +246,15 @@ PrintString: # nul-terminated in si
|
||||||
jmp 0b
|
jmp 0b
|
||||||
1: ret
|
1: ret
|
||||||
|
|
||||||
|
PutChar:push %bx # don't clobber bp,bx,di,si,cx
|
||||||
|
push %bp # original ibm pc scroll up bug
|
||||||
|
mov $7,%bx # normal mda/cga style page zero
|
||||||
|
mov $0x0e,%ah # teletype output al cp437
|
||||||
|
int $0x10 # vidya service
|
||||||
|
pop %bp # preserves al
|
||||||
|
pop %bx
|
||||||
|
ret
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
.text
|
.text
|
||||||
|
|
||||||
|
|
@ -283,15 +288,6 @@ PrintObject:
|
||||||
// jmp PutChar
|
// jmp PutChar
|
||||||
// 𝑠𝑙𝑖𝑑𝑒
|
// 𝑠𝑙𝑖𝑑𝑒
|
||||||
|
|
||||||
PutChar:push %bx # don't clobber bp,bx,di,si,cx
|
|
||||||
push %bp # original ibm pc scroll up bug
|
|
||||||
mov $7,%bx # normal mda/cga style page zero
|
|
||||||
mov $0x0e,%ah # teletype output al cp437
|
|
||||||
int $0x10 # vidya service
|
|
||||||
pop %bp # preserves al
|
|
||||||
pop %bx
|
|
||||||
ret
|
|
||||||
|
|
||||||
Arg1ds: mov %dx,%di
|
Arg1ds: mov %dx,%di
|
||||||
mov %bp,%si
|
mov %bp,%si
|
||||||
// 𝑠𝑙𝑖𝑑𝑒
|
// 𝑠𝑙𝑖𝑑𝑒
|
||||||
|
|
|
||||||
10
start.S
10
start.S
|
|
@ -24,14 +24,12 @@ _start: jmp 1f # some bios scan for short jump
|
||||||
1: ljmp $0x600>>4,$_begin # end of bios data roundup page
|
1: ljmp $0x600>>4,$_begin # end of bios data roundup page
|
||||||
|
|
||||||
_begin: push %cs # memory model cs=ds=es = 0x600
|
_begin: push %cs # memory model cs=ds=es = 0x600
|
||||||
pop %ds
|
|
||||||
push %cs
|
push %cs
|
||||||
|
push %cs
|
||||||
|
pop %ds
|
||||||
pop %es
|
pop %es
|
||||||
mov $0x70000>>4,%ax # last 64k of first 480k memory
|
pop %ss
|
||||||
cli # create stack in higher memory
|
mov $0x70000>>4,%sp
|
||||||
mov %ax,%ss # carefully avoids i8086 errata
|
|
||||||
xor %sp,%sp
|
|
||||||
sti
|
|
||||||
cld
|
cld
|
||||||
xor %ax,%ax
|
xor %ax,%ax
|
||||||
xor %di,%di
|
xor %di,%di
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue