From e40c059c2619e0c0cfe324e4e690830ce960086d Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 15 Apr 2020 14:00:59 -0400 Subject: [PATCH] Make word routines all in the <0x100 range --- emul/forth/z80c.bin | Bin 2240 -> 2239 bytes forth/boot.fs | 82 ++++++++++++++++++++++++++-------------------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index f377d790c4722b055c3787e356b2999e5d75a9d8..19c0d5793e5f6ffb23fc564c59d920cd07f7b540 100644 GIT binary patch delta 1221 zcmYjQO-~bH5T4oHE`{Ji!4HC%EMH0yg=mOTi+n6A)IeLxA|-%?@?l65Xb=yass|D- z#2~*wV>FTwV+>r??1A*)iI5QCfCtQasPRrno!J+Z9=7{FGw(CcJTv>n_u1EIzXLlB z?$2IA`zhLaXrIHQUtmYjZo~yxfdvZNA;*4+;(v0vF>;|+bskkdtgKL-ZMzicbnu}g zocXw%s>0XHZyuw*l8;x*+A%YzI`Kqtai-V3uzmF7+a)-fhRd*GVT0F4jK8mJolA;7^Qs?gIHvFIDXe5o9(37y)z=F0|K8%lH;ReV?|szjXIQr zP{9ig_4&~*+fn-aZf8x=&e~3LwV_asUYg9N1 zCC4>vX~)CK>$oL3)C|8nIPXa#>!>E86f^B2b0gTKB`&YiNu)Sg(aAdQ(q%Cde}awO z@vKQnnnHlOGy;Vnv5ooUe~Zkf)fKQ2n{=v|`Kg0MS+UGv!9Pw21ci zHeUpp*~-aeA&RZG!u{cBdkI@Ppr-MyD(bWL82l!8I9w){Ln9qu)kCbOy38ytBq@zM z=BNR^Mr5Fl(o@IIExLp%(XmT>D+WJ_c5q^PZgzh73OCJ?9W2NZ9U<`OShYj$GRDib zB_-5FRh+on8uz}xiSO^Lw{wjDE9Qe-4O06mx&z~)yoIYY39*kc`W7~ba+Ny#PEu;( zGc$7m|4pXS;ks)!&+BA%0^_1>;jmRDypSkuk7z4S#^)~f1|h7L=FdECSg^ZcF-k^* zp&)+>Ns_`c*qz?g=h$hDF{LlO(P*ONF`-iu@PEmw^BqzC}5NZDiRa9R1-bm z!HE0^Tr|O8j0qh5u|1F`-pT<}4jd%yp(fru(A1fItB73rvkD9zY)l?F|05Y^6Hf!#fc4IO>&79QUiE>x)vA= zXgUa%G+SpXczXN+y@|9PiYF{8xXXYk;FdN}cUSS*0fmAWV^@#!m;)Hlc|0~X5s6e$ z;UsfFJ%lVV>?MuQ3{))af_O@x5F7~=3aXi22Gjr23Cm($IUEQHf$~cpO*wCqM@beD ziRc0rjzLYaMnc%NQ1T{A30Z80p0jMpl4PXg91_KeDb0wRK?1cz#7#W$luUtlvdPkT zna{*IOUCY6HiQ^X!Hr$2U6mk^jmOY`k4UDqRge+ecyfvK>i_}Cx6x!wZ>yzrf`j6A z+>BCb9vu#Lp8}EC>d|B_imcZC!~Q^T4Ow|hPO`T$uTR>;@C)6c@M*pr3hMYKA2Ju# zC1!phhH2C>MO6r@gClL29xpn#Y!b>yM=sH=FdQK5==9v;!jrLPYMLZxS*4YC#DGRe zs$NZU{vpSjpuh>%*GKk=Ah z&TfYJC<*oYy!0x>PzuQ)e_mk^{a)QS#tS$gDo15(YhXa@?KXFvT1g2JWPb_|aCTR! w;h6%BxM)#%Pb7ys&HY%iI^dFmAot)Tj^eJZR7yfTj7!QLxMAZSjCTP03ouU?u>b%7 diff --git a/forth/boot.fs b/forth/boot.fs index cebf372..3081cd8 100644 --- a/forth/boot.fs +++ b/forth/boot.fs @@ -86,6 +86,46 @@ H@ XCURRENT ! ( set current tip of dict ) ( END OF STABLE ABI ) +( We want numberWord and litWord routine to be below the 0x100 + offset so that we can reduce the size of the routine field + in words to 1 byte. ) +( addrWord is the exact same thing as a numberWord except that + it is treated differently by meta-tools. See notes.txt ) +PC ORG @ 0x20 + ! ( numberWord ) +PC ORG @ 0x24 + ! ( addrWord ) +( This is not a word, but a number literal. This works a bit + differently than others: PF means nothing and the actual + number is placed next to the numberWord reference in the + compiled word list. What we need to do to fetch that number + is to play with the IP. +) + RAMSTART 0x06 + LDHL(nn), ( RAMSTART+0x06 == IP ) + E (HL) LDrr, + HL INCss, + D (HL) LDrr, + HL INCss, + RAMSTART 0x06 + LD(nn)HL, ( RAMSTART+0x06 == IP ) + DE PUSHqq, + JPNEXT, + +PC ORG @ 0x22 + ! ( litWord ) +( Similarly to numberWord, this is not a real word, but a + string literal. Instead of being followed by a 2 bytes + number, it's followed by a null-terminated string. When + called, puts the string's address on PS ) + RAMSTART 0x06 + LDHL(nn), ( RAMSTART+0x06 == IP ) + HL PUSHqq, + ( skip to null char ) + A XORr, ( look for null ) + B A LDrr, + C A LDrr, + CPIR, + ( CPIR advances HL regardless of comparison, so goes one + char after NULL. This is good, because that's what we + want... ) + RAMSTART 0x06 + LD(nn)HL, ( RAMSTART+0x06 == IP ) + JPNEXT, + ( Name of BOOT word ) L1 BSET 'B' A, 'O' A, 'O' A, 'T' A, 0 A, @@ -272,15 +312,13 @@ PC ORG @ 0x34 + ! ( execute ) IY POPqq, ( is a wordref ) chkPS, L 0 IY+ LDrIXY, - H 1 IY+ LDrIXY, + H 0 LDrn, ( HL points to code pointer ) IY INCss, IY INCss, ( IY points to PFA ) JP(HL), -( WORD ROUTINES ) - PC ORG @ 0x0f + ! ( compiledWord ) ( Execute a list of atoms, which always end with EXIT. IY points to that list. What do we do: @@ -317,41 +355,3 @@ PC ORG @ 0x2c + ! ( doesWord ) H 3 IY+ LDrIXY, HL PUSHqq, IY POPqq, 0x0e JPnn, ( 0e == compiledWord ) - - -( addrWord is the exact same thing as a numberWord except that - it is treated differently by meta-tools. See notes.txt ) -PC ORG @ 0x20 + ! ( numberWord ) -PC ORG @ 0x24 + ! ( addrWord ) -( This is not a word, but a number literal. This works a bit - differently than others: PF means nothing and the actual - number is placed next to the numberWord reference in the - compiled word list. What we need to do to fetch that number - is to play with the IP. -) - RAMSTART 0x06 + LDHL(nn), ( RAMSTART+0x06 == IP ) - E (HL) LDrr, - HL INCss, - D (HL) LDrr, - HL INCss, - RAMSTART 0x06 + LD(nn)HL, ( RAMSTART+0x06 == IP ) - DE PUSHqq, - JPNEXT, - -PC ORG @ 0x22 + ! ( litWord ) -( Similarly to numberWord, this is not a real word, but a - string literal. Instead of being followed by a 2 bytes - number, it's followed by a null-terminated string. When - called, puts the string's address on PS ) - RAMSTART 0x06 + LDHL(nn), ( RAMSTART+0x06 == IP ) - HL PUSHqq, - ( skip to null char ) - A XORr, ( look for null ) - B A LDrr, - C A LDrr, - CPIR, - ( CPIR advances HL regardless of comparison, so goes one - char after NULL. This is good, because that's what we - want... ) - RAMSTART 0x06 + LD(nn)HL, ( RAMSTART+0x06 == IP ) - JPNEXT,