mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-24 02:28:06 +11:00
forth: a little bit of ASM routine inlining
This commit is contained in:
parent
5c03b33982
commit
e5ab0dd1c9
@ -29,7 +29,7 @@ trouble of compiling defs to binary.
|
|||||||
|
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
// in sync with glue.asm
|
// in sync with glue.asm
|
||||||
#define RAMSTART 0x850
|
#define RAMSTART 0x840
|
||||||
#define STDIO_PORT 0x00
|
#define STDIO_PORT 0x00
|
||||||
// To know which part of RAM to dump, we listen to port 2, which at the end of
|
// To know which part of RAM to dump, we listen to port 2, which at the end of
|
||||||
// its compilation process, spits its HERE addr to port 2 (MSB first)
|
// its compilation process, spits its HERE addr to port 2 (MSB first)
|
||||||
|
Binary file not shown.
@ -190,17 +190,6 @@ forthMain:
|
|||||||
.bootName:
|
.bootName:
|
||||||
.db "BOOT", 0
|
.db "BOOT", 0
|
||||||
|
|
||||||
; copy (HL) into DE, then exchange the two, utilising the optimised HL instructions.
|
|
||||||
; ld must be done little endian, so least significant byte first.
|
|
||||||
intoHL:
|
|
||||||
push de
|
|
||||||
ld e, (hl)
|
|
||||||
inc hl
|
|
||||||
ld d, (hl)
|
|
||||||
ex de, hl
|
|
||||||
pop de
|
|
||||||
ret
|
|
||||||
|
|
||||||
; Compares strings pointed to by HL and DE until one of them hits its null char.
|
; Compares strings pointed to by HL and DE until one of them hits its null char.
|
||||||
; If equal, Z is set. If not equal, Z is reset. C is set if HL > DE
|
; If equal, Z is set. If not equal, Z is reset. C is set if HL > DE
|
||||||
strcmp:
|
strcmp:
|
||||||
@ -225,19 +214,6 @@ strcmp:
|
|||||||
; early, set otherwise)
|
; early, set otherwise)
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Given a string at (HL), move HL until it points to the end of that string.
|
|
||||||
strskip:
|
|
||||||
push bc
|
|
||||||
ex af, af'
|
|
||||||
xor a ; look for null char
|
|
||||||
ld b, a
|
|
||||||
ld c, a
|
|
||||||
cpir ; advances HL regardless of comparison, so goes one too far
|
|
||||||
dec hl
|
|
||||||
ex af, af'
|
|
||||||
pop bc
|
|
||||||
ret
|
|
||||||
|
|
||||||
; Parse string at (HL) as a decimal value and return value in DE.
|
; Parse string at (HL) as a decimal value and return value in DE.
|
||||||
; Reads as many digits as it can and stop when:
|
; Reads as many digits as it can and stop when:
|
||||||
; 1 - A non-digit character is read
|
; 1 - A non-digit character is read
|
||||||
@ -376,8 +352,10 @@ find:
|
|||||||
dec de \ dec de \ dec de ; prev field
|
dec de \ dec de \ dec de ; prev field
|
||||||
push de ; --> lvl 2
|
push de ; --> lvl 2
|
||||||
ex de, hl
|
ex de, hl
|
||||||
call intoHL
|
ld e, (hl)
|
||||||
ex de, hl ; DE contains prev offset
|
inc hl
|
||||||
|
ld d, (hl)
|
||||||
|
; DE contains prev offset
|
||||||
pop hl ; <-- lvl 2
|
pop hl ; <-- lvl 2
|
||||||
; HL is prev field's addr
|
; HL is prev field's addr
|
||||||
; Is offset zero?
|
; Is offset zero?
|
||||||
@ -543,8 +521,13 @@ numberWord:
|
|||||||
litWord:
|
litWord:
|
||||||
ld hl, (IP)
|
ld hl, (IP)
|
||||||
push hl
|
push hl
|
||||||
call strskip
|
; Skip to null char
|
||||||
inc hl ; after null termination
|
xor a ; look for null char
|
||||||
|
ld b, a
|
||||||
|
ld c, a
|
||||||
|
cpir
|
||||||
|
; CPIR advances HL regardless of comparison, so goes one char after
|
||||||
|
; NULL. This is good, because that's what we want...
|
||||||
ld (IP), hl
|
ld (IP), hl
|
||||||
jp next
|
jp next
|
||||||
|
|
||||||
@ -558,5 +541,5 @@ litWord:
|
|||||||
.dw $-EXECUTE
|
.dw $-EXECUTE
|
||||||
.db 5
|
.db 5
|
||||||
|
|
||||||
; Offset: 0249
|
; Offset: 0237
|
||||||
.out $
|
.out $
|
||||||
|
Loading…
Reference in New Issue
Block a user