From 594b3c33481bab12f8115177ee2c8446035b83cb Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 8 Dec 2020 21:51:05 -0500 Subject: [PATCH] Add ~C! to override memory low level write routines Also, turn AT28! and AT28, into ~AT28, pluggable into ~C!. ~AT28 doesn't check for mismatches. It was too complicated to turn a mismatch into a compiled word we would jump to next. Data integrity has to be checked through another path. Also, remove MOVEW. Without indirect memory access, this word doesn't make sense. Some AVR-specific words will have to be defined. --- blk.fs | 53 +++++++++++++++++++++++--------------------------- cvm/stage.bin | Bin 5008 -> 4960 bytes doc/dict.txt | 15 ++++++++------ doc/impl.txt | 12 ++++++++---- 4 files changed, 41 insertions(+), 39 deletions(-) diff --git a/blk.fs b/blk.fs index f023d0a..1aed37f 100644 --- a/blk.fs +++ b/blk.fs @@ -1048,6 +1048,11 @@ VARIABLE lbluflw VARIABLE lblexec ( 7.373MHz target: 737t. outer: 37t inner: 16t ) ( tickfactor = (737 - 37) / 16 ) CREATE tickfactor 44 , +( Perform a byte write by taking into account the SYSVARS+3e + override. ) +: LD(HL)E*, SYSVARS 0x3e + LDA(i), A ORr, + IFZ, (HL) E LDrr, ELSE, SYSVARS 0x3e + CALL, THEN, ; + ( ----- 283 ) H@ ORG ! ( STABLE ABI ) 0 JP, ( 00, main ) NOP, ( unused ) NOP, NOP, ( 04, BOOT ) @@ -1072,6 +1077,7 @@ HERESTART [IF] HL HERESTART LDdi, [THEN] SYSVARS 0x04 + LD(i)HL, ( RAM+04 == HERE ) + A XORr, SYSVARS 0x3e + LD(i)A, ( 3e == ~C! ) DE BIN( @ 0x04 ( BOOT ) + LDd(i), JR, L1 FWR ( execute, B287 ) ( ----- 286 ) @@ -1458,9 +1464,8 @@ CODE TICKS ( ----- 322 ) CODE ! HL POP, DE POP, chkPS, - (HL) E LDrr, - HL INCd, - (HL) D LDrr, + LD(HL)E*, HL INCd, + E D LDrr, LD(HL)E*, ;CODE CODE @ HL POP, chkPS, @@ -1472,14 +1477,17 @@ CODE @ ( ----- 323 ) CODE C! HL POP, DE POP, chkPS, - (HL) E LDrr, -;CODE - + LD(HL)E*, ;CODE CODE C@ HL POP, chkPS, L (HL) LDrr, - H 0 LDri, - HL PUSH, + H 0 LDri, HL PUSH, ;CODE +CODE ~C! + HL POP, chkPS, + SYSVARS 0x3f + LD(i)HL, + HLZ, ( makes A zero if Z is set ) IFNZ, + A 0xc3 ( JP ) LDri, THEN, + ( A is either 0 or c3 ) SYSVARS 0x3e + LD(i)A, ;CODE ( ----- 324 ) CODE PC! EXX, ( protect BC ) @@ -1862,12 +1870,6 @@ SYSVARS 0x0c + :** C<* LOOP THEN 2DROP ; : MOVE, ( a u -- ) H@ OVER ALLOT SWAP MOVE ; ( ----- 368 ) -: MOVEW ( src dst u -- ) - ( u ) 0 DO - SWAP DUP I 1 LSHIFT + C@ ( dst src x ) - ROT TUCK I 1 LSHIFT + ( src dst x dst ) - C! ( src dst ) - LOOP 2DROP ; : PREV 3 - DUP @ - ; : [entry] ( w -- ) C@+ ( w+1 len ) TUCK MOVE, ( len ) @@ -2162,21 +2164,14 @@ XCURRENT @ _xapply ORG @ 0x04 ( stable ABI BOOT ) + ! ':' X' _ 4 - C! ( give : its name ) '(' X' _ 4 - C! ( ----- 400 ) -( With dst being assumed to be an AT28 EEPROM, perform C! - operation while doing the right thing. Checks data integrity - and ABORT on mismatch. ) -: _ ( n a -- wait until addr is "stable", err on mismatch ) - ( as long as writing operation is running, IO/6 will toggle - at each read attempt. We know that write is finished when - we read the same value twice. ) - BEGIN ( n1 a ) - DUP C@ ( n1 a n2 ) - OVER C@ ( n1 a n2 n3 ) - = UNTIL - ( We're finished writing. do we have a mismatch? ) - C@ SWAP 0xff AND = NOT IF ABORT" mismatch" THEN ; -: AT28! ( n a -- ) 2DUP C! _ ; -: AT28, ( n -- ) H@ 2DUP C! DUP 1+ HERE ! _ ; +( Write byte E at addr HL, assumed to be an AT28 EEPROM. + After that, poll repeatedly that address until writing is + complete. ) +(entry) ~AT28 ( warning: don't touch D register ) + (HL) E LDrr, E (HL) LDrr, ( poll ) BEGIN, + A (HL) LDrr, ( poll ) E CPr, ( same as old? ) + E A LDrr, ( save old poll, Z preserved ) + JRNZ, AGAIN, RET, ( ----- 401 ) Grid subsystem diff --git a/cvm/stage.bin b/cvm/stage.bin index 435f81365028043ac1cbc2b933824de4dc70c178..5d38b15d750a9af58ad9aba4195a900a4a072564 100644 GIT binary patch delta 878 zcmYjQOH31C5T4oorEGV*-Ik~r79Xjtv`q^25luy*TPlLJEkzMSl!xiX;3L$Co{XW1 ziAqp^sOhOaC>%VgXD}KL96T5k-cq%0Jj2qK{vYyf-&X^;kwmw+4FR_)ae{(mc3o_uy6FXuNB1 zG;yl?SS?sd^{Mz9t@gK^0))Z>zwppulbTCup1>vTt&AT#ty zIzTJqIKUPtondZk*+jh*@u1|B2B00oRLfQ%6pNM!{GfhQ=`-6YbX+PySu(1O@TA;@ zUS5{BVUoX;o0|*r6f=$nq28?^;7^>B=VT4~?SO<;hX_ouJj}_2MyiEzC%C9N=u!%oa>Ke+_kZLAu z#~HJf9ez`^Wtk<-YOU0gLcD)ho*?6sPS36~HL61h{$M@oaKx!YwJ8@#t1_iEg@1JV z2g{NdoV|pi^4<#u)rnNJEqITpH3lHykh5aSsAQVK5*QTbAt|r3A!h_uH(rApaa@Tg znWGcPmGP|FM9>OqnC=BNC{W>FYUt8)RVTju#8oRv(+)#gqO)$=48-Sbe)d1!^GYYM z{@jh+tk?-s?DFvN;FVl55 z1X60p10I^sYtda_z#@@!j=F4 delta 926 zcmY*YK}-`-5S`g>Dc$XMx2*;YTU4M(TT`skOG6^vQV=L96e%cCN}|R?MG`z{G#Ek? zFD5Eq&>l<)gmCcW&BUN5IhoiP!x`aXq7YPKJQ(8qtsdOu|NNOhf9Ab6vm1>MkJ*8L zt}1Kph5fNT(woX8hTLF9hFK^=9y+mrA5g$B-hpY$KP!My*jxi0`qGKaakglWH*VW? zh^G^=vk3(%&@CAtz!RGenOM3jW+W3HsKh#n$x_7DBk6({KeA3~#9AlK*jCtzG>aJ) zm3?$)2M=5Xq{?23j|OA-~t5BRM#5rkY@Okh>Wyi?SKrrcrbrc>EWk z8Lab!a8>3GFM7-b<)oC=O1#RshPwI)vWOYk0B945xcH0Gad-RagT$qPSLKYHB`LyG z%QjCaHY`#2MtoC!=MK};Rk;WynO9k4wT^xqWD|~BoMI0gt*vX0Igu|NLc@nZz#q8d z*m3AEDghE!1EMe|=3&RND;gkD?kuTZk6(Ehvnl;TmBP*|xteu_2TQ<-5e5SkihHFH z%Q^N*If+~BfHRD3ti#!YS$5l5(^MitnwhW@SIklp{G`{GU2)2+)<%?^r2A{lxDR+4?74ik#<{V;H;lc`vH@IFb)8zA7U zT6U#1a;;zyxP*C_a_ozk2<@(b_kC9Pve)U;GcRvm3 diff --git a/doc/dict.txt b/doc/dict.txt index ab0a53a..c0158cb 100644 --- a/doc/dict.txt +++ b/doc/dict.txt @@ -152,6 +152,7 @@ J -- n Copy RS third item to PS , n -- Write n in HERE and advance it. ? a -- Print value of addr a +! n a -- Increase value of addr a by n +~C! a -- Set C! and ! overrides. See notes. C@ a -- c Set c to byte at address a C@+ a -- a+1 c Fetch c from a and inc a. C@- a -- a-1 c Fetch c from a and dec a. @@ -173,13 +174,15 @@ MOVE a1 a2 u -- Copy u bytes from a1 to a2, starting MOVE- a1 a2 u -- Copy u bytes from a1 to a2, starting with a1+u, going down. MOVE, a u -- Copy u bytes from a to HERE. -MOVEW src dst u -- Same as MOVE, but with words -MOVEW notes: this word's purpose is to interface with word- -based systems. src and dst are addressed as *bytes* but u is a -*word* count. Every iteration increases src and dst by 2. This -shouldn't be used on regular memory, it will yield weird -results. Use it with C!* ialias pointing to a word-based target. +Notes: + +~C!: When supplied a non-zero address, sets the SYSVARS+3e (see + impl.txt) override routine address. This should link dir- + ectly to assembly code because we call this address. This + routine shouldn't end with a call to next, but rather a + regular assembly return. Registers used are arch-specific. + When supplied 0, unsets override. # Arithmetic / Bits diff --git a/doc/impl.txt b/doc/impl.txt index 2d9d38f..ca25816 100644 --- a/doc/impl.txt +++ b/doc/impl.txt @@ -159,10 +159,10 @@ offsets, but thankfully, there aren't many system variables. Here's a list of them: SYSVARS FUTURE USES +3c BLK(* -+02 CURRENT +3e FUTURE USES -+04 HERE +40 FUTURE USES -+06 C