diff --git a/emul/forth/stage.c b/emul/forth/stage.c index 060d720..523c9c1 100644 --- a/emul/forth/stage.c +++ b/emul/forth/stage.c @@ -29,7 +29,7 @@ trouble of compiling defs to binary. //#define DEBUG // in sync with glue.asm -#define RAMSTART 0x850 +#define RAMSTART 0x840 #define STDIO_PORT 0x00 // 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) diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index 8056642..0133c1b 100644 Binary files a/emul/forth/z80c.bin and b/emul/forth/z80c.bin differ diff --git a/forth/forth.asm b/forth/forth.asm index 68ee473..92fd968 100644 --- a/forth/forth.asm +++ b/forth/forth.asm @@ -190,17 +190,6 @@ forthMain: .bootName: .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. ; If equal, Z is set. If not equal, Z is reset. C is set if HL > DE strcmp: @@ -225,19 +214,6 @@ strcmp: ; early, set otherwise) 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. ; Reads as many digits as it can and stop when: ; 1 - A non-digit character is read @@ -376,8 +352,10 @@ find: dec de \ dec de \ dec de ; prev field push de ; --> lvl 2 ex de, hl - call intoHL - ex de, hl ; DE contains prev offset + ld e, (hl) + inc hl + ld d, (hl) + ; DE contains prev offset pop hl ; <-- lvl 2 ; HL is prev field's addr ; Is offset zero? @@ -543,8 +521,13 @@ numberWord: litWord: ld hl, (IP) push hl - call strskip - inc hl ; after null termination + ; Skip to null char + 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 jp next @@ -558,5 +541,5 @@ litWord: .dw $-EXECUTE .db 5 -; Offset: 0249 +; Offset: 0237 .out $