From e5ab0dd1c9a87e0ff865b3701a11479957e5d0ba Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 30 Mar 2020 21:33:37 -0400 Subject: [PATCH] forth: a little bit of ASM routine inlining --- emul/forth/stage.c | 2 +- emul/forth/z80c.bin | Bin 1549 -> 1549 bytes forth/forth.asm | 41 ++++++++++++----------------------------- 3 files changed, 13 insertions(+), 30 deletions(-) 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 8056642322800b15bde44f41b744e5a47ce70f47..0133c1b74cf00c22843fa5fcd53201987da4d04d 100644 GIT binary patch delta 559 zcmYL`ze_?<6vw~b`|dTvUQ;3DU{cYe8XBC6q8~yJA=9J`hlrO^6!9=4nk1SGY;kNC z8jLn+Ym}Cjrdn!=D2Spzpw3aN<#IXS@4e@9zNh3b`7hU{y6Adr+bnO%r9xHJYPIygpsEBl7AfUOP+uF@rU0hFy zH<=KuX;g)ceHDTSF`35mH#zq=b`GooXcJ-V<=33;k@AGmUYOSW&&+rb!bAxEm%3zt znPHO)x2i55B%jT{Zi(2&^5SF21cycztJx+8&T~21HXbtgb4Dh8F)h|ef24xgiWEyZ!q-SIiXPO;P z4amPxC*d>krAL*E05$f2W3SK+bo13HpEg{pdO5Cw6P*7w$zcpS;})%hC-75ZvFJ); zIh;^S?ql7h#}%Y$9gc9y=PEeY>m_~^TOGS;EvLr6t4Q88(SL-1CX3P4B45IptzIVN~V_kdB%dM*V_hX;DVG5ZM;o2kBW^!oAKJA1%l~ zQy0)}LK!jTp`Qi^z_wTD2l{o_$e%9MRim6#;d%DIPI3g}Zq%Z4@CG4rY&E{!Iu1M3 zkw;kfsJMbOox>M?`A&sbW(?v-sWY*U&T^~$XO$>7$m59M(@3L1uFTEioGr1bs-XFF Jy4@ZGegFfkfmHwi 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 $