1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 12:58:06 +11:00

Add ~C!ERR

A ~C! override can, if it wants, go put an error code in there,
which ~AT28 does.

This way, after a copy or xcomp process directly to EEPROM, one
can verify whether all bytes were successfully written by checking
whether "~C!ERR C@" is zero.
This commit is contained in:
Virgil Dupras 2020-12-09 19:44:02 -05:00
parent dda80801d5
commit cbd9f035ae
3 changed files with 20 additions and 10 deletions

17
blk.fs
View File

@ -1078,6 +1078,7 @@ HERESTART [IF]
[THEN]
SYSVARS 0x04 + LD(i)HL, ( RAM+04 == HERE )
A XORr, SYSVARS 0x3e + LD(i)A, ( 3e == ~C! )
SYSVARS 0x41 + LD(i)A, ( 41 == ~C!ERR )
DE BIN( @ 0x04 ( BOOT ) + LDd(i),
JR, L1 FWR ( execute, B287 )
( ----- 286 )
@ -1689,7 +1690,7 @@ driver code. Load the low part with "353 LOAD", the high part
with "390 LOAD"
( ----- 353 )
: RAM+ [ SYSVARS LITN ] + ; : BIN+ [ BIN( @ LITN ] + ;
: HERE 0x04 RAM+ ;
: HERE 0x04 RAM+ ; : ~C!ERR 0x41 RAM+ ;
: CURRENT* 0x51 RAM+ ; : CURRENT CURRENT* @ ;
: H@ HERE @ ;
: FIND ( w -- a f ) CURRENT @ SWAP _find ;
@ -2159,14 +2160,18 @@ XCURRENT @ _xapply ORG @ 0x04 ( stable ABI BOOT ) + !
':' X' _ 4 - C! ( give : its name )
'(' X' _ 4 - C!
( ----- 400 )
( Write byte E at addr HL, assumed to be an AT28 EEPROM.
After that, poll repeatedly that address until writing is
complete. )
( Write byte E at addr HL, assumed to be an AT28 EEPROM. After
that, poll repeatedly that address until writing is complete.
If last polled value is different than orig, set ~C!ERR )
(entry) ~AT28 ( warning: don't touch D register )
(HL) E LDrr, E (HL) LDrr, ( poll ) BEGIN,
(HL) E LDrr, A E LDrr, ( orig ) EXAFAF', ( save )
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,
JRNZ, AGAIN,
EXAFAF', ( orig ) E SUBr, ( equal? )
IFNZ, SYSVARS 0x41 + ( ~C!ERR ) LD(i)A, THEN,
RET,
( ----- 401 )
Grid subsystem

Binary file not shown.

View File

@ -160,9 +160,9 @@ Here's a list of them:
SYSVARS FUTURE USES +3c BLK(*
+02 CURRENT +3e ~C!*
+04 HERE +41 FUTURE USES
+06 C<? +43 FUTURE USES
+08 C<* override +45 FUTURE USES
+04 HERE +41 ~C!ERR
+06 C<? +42 FUTURE USES
+08 C<* override +43 FUTURE USES
+0a NL ialias +51 CURRENTPTR
+0c C<* +53 EMIT ialias
+0e WORDBUF +55 KEY ialias
@ -197,6 +197,10 @@ BLK* "Disk blocks" in usage.txt.
the routine that writes a byte to memory and then returns.
Register usage is arch-dependent, see boot code for details.
~C!ERR: When an error happens during ~C! write overrides, sets
this byte to a nonzero value. Otherwise, stays at zero. Has to
be reset to zero manually after an error.
DRIVERS section is reserved for recipe-specific drivers.
FUTURE USES section is unused for now.
@ -214,7 +218,8 @@ very few things.
2. Set CURRENT to value of LATEST field in stable ABI.
3. Set HERE to HERESTART const if defined, to CURRENT other-
wise.
4. Execute the word referred to by 0x04 (BOOT) in stable ABI.
4. Initialize ~C! and ~C!ERR to 0.
5. Execute the word referred to by 0x04 (BOOT) in stable ABI.
In a normal system, BOOT is in core words at B396 and does a
few things: