mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 09:48:05 +11:00
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.
This commit is contained in:
parent
953e040231
commit
594b3c3348
53
blk.fs
53
blk.fs
@ -1048,6 +1048,11 @@ VARIABLE lbluflw VARIABLE lblexec
|
|||||||
( 7.373MHz target: 737t. outer: 37t inner: 16t )
|
( 7.373MHz target: 737t. outer: 37t inner: 16t )
|
||||||
( tickfactor = (737 - 37) / 16 )
|
( tickfactor = (737 - 37) / 16 )
|
||||||
CREATE tickfactor 44 ,
|
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 )
|
( ----- 283 )
|
||||||
H@ ORG ! ( STABLE ABI )
|
H@ ORG ! ( STABLE ABI )
|
||||||
0 JP, ( 00, main ) NOP, ( unused ) NOP, NOP, ( 04, BOOT )
|
0 JP, ( 00, main ) NOP, ( unused ) NOP, NOP, ( 04, BOOT )
|
||||||
@ -1072,6 +1077,7 @@ HERESTART [IF]
|
|||||||
HL HERESTART LDdi,
|
HL HERESTART LDdi,
|
||||||
[THEN]
|
[THEN]
|
||||||
SYSVARS 0x04 + LD(i)HL, ( RAM+04 == HERE )
|
SYSVARS 0x04 + LD(i)HL, ( RAM+04 == HERE )
|
||||||
|
A XORr, SYSVARS 0x3e + LD(i)A, ( 3e == ~C! )
|
||||||
DE BIN( @ 0x04 ( BOOT ) + LDd(i),
|
DE BIN( @ 0x04 ( BOOT ) + LDd(i),
|
||||||
JR, L1 FWR ( execute, B287 )
|
JR, L1 FWR ( execute, B287 )
|
||||||
( ----- 286 )
|
( ----- 286 )
|
||||||
@ -1458,9 +1464,8 @@ CODE TICKS
|
|||||||
( ----- 322 )
|
( ----- 322 )
|
||||||
CODE !
|
CODE !
|
||||||
HL POP, DE POP, chkPS,
|
HL POP, DE POP, chkPS,
|
||||||
(HL) E LDrr,
|
LD(HL)E*, HL INCd,
|
||||||
HL INCd,
|
E D LDrr, LD(HL)E*,
|
||||||
(HL) D LDrr,
|
|
||||||
;CODE
|
;CODE
|
||||||
CODE @
|
CODE @
|
||||||
HL POP, chkPS,
|
HL POP, chkPS,
|
||||||
@ -1472,14 +1477,17 @@ CODE @
|
|||||||
( ----- 323 )
|
( ----- 323 )
|
||||||
CODE C!
|
CODE C!
|
||||||
HL POP, DE POP, chkPS,
|
HL POP, DE POP, chkPS,
|
||||||
(HL) E LDrr,
|
LD(HL)E*, ;CODE
|
||||||
;CODE
|
|
||||||
|
|
||||||
CODE C@
|
CODE C@
|
||||||
HL POP, chkPS,
|
HL POP, chkPS,
|
||||||
L (HL) LDrr,
|
L (HL) LDrr,
|
||||||
H 0 LDri,
|
H 0 LDri, HL PUSH, ;CODE
|
||||||
HL PUSH,
|
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
|
;CODE
|
||||||
( ----- 324 )
|
( ----- 324 )
|
||||||
CODE PC! EXX, ( protect BC )
|
CODE PC! EXX, ( protect BC )
|
||||||
@ -1862,12 +1870,6 @@ SYSVARS 0x0c + :** C<*
|
|||||||
LOOP THEN 2DROP ;
|
LOOP THEN 2DROP ;
|
||||||
: MOVE, ( a u -- ) H@ OVER ALLOT SWAP MOVE ;
|
: MOVE, ( a u -- ) H@ OVER ALLOT SWAP MOVE ;
|
||||||
( ----- 368 )
|
( ----- 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 @ - ;
|
: PREV 3 - DUP @ - ;
|
||||||
: [entry] ( w -- )
|
: [entry] ( w -- )
|
||||||
C@+ ( w+1 len ) TUCK MOVE, ( len )
|
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! ( give : its name )
|
||||||
'(' X' _ 4 - C!
|
'(' X' _ 4 - C!
|
||||||
( ----- 400 )
|
( ----- 400 )
|
||||||
( With dst being assumed to be an AT28 EEPROM, perform C!
|
( Write byte E at addr HL, assumed to be an AT28 EEPROM.
|
||||||
operation while doing the right thing. Checks data integrity
|
After that, poll repeatedly that address until writing is
|
||||||
and ABORT on mismatch. )
|
complete. )
|
||||||
: _ ( n a -- wait until addr is "stable", err on mismatch )
|
(entry) ~AT28 ( warning: don't touch D register )
|
||||||
( as long as writing operation is running, IO/6 will toggle
|
(HL) E LDrr, E (HL) LDrr, ( poll ) BEGIN,
|
||||||
at each read attempt. We know that write is finished when
|
A (HL) LDrr, ( poll ) E CPr, ( same as old? )
|
||||||
we read the same value twice. )
|
E A LDrr, ( save old poll, Z preserved )
|
||||||
BEGIN ( n1 a )
|
JRNZ, AGAIN, RET,
|
||||||
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 ! _ ;
|
|
||||||
( ----- 401 )
|
( ----- 401 )
|
||||||
Grid subsystem
|
Grid subsystem
|
||||||
|
|
||||||
|
BIN
cvm/stage.bin
BIN
cvm/stage.bin
Binary file not shown.
15
doc/dict.txt
15
doc/dict.txt
@ -152,6 +152,7 @@ J -- n Copy RS third item to PS
|
|||||||
, n -- Write n in HERE and advance it.
|
, n -- Write n in HERE and advance it.
|
||||||
? a -- Print value of addr a
|
? a -- Print value of addr a
|
||||||
+! n a -- Increase value of addr a by n
|
+! 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 -- 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 inc a.
|
||||||
C@- a -- a-1 c Fetch c from a and dec 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
|
MOVE- a1 a2 u -- Copy u bytes from a1 to a2, starting
|
||||||
with a1+u, going down.
|
with a1+u, going down.
|
||||||
MOVE, a u -- Copy u bytes from a to HERE.
|
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-
|
Notes:
|
||||||
based systems. src and dst are addressed as *bytes* but u is a
|
|
||||||
*word* count. Every iteration increases src and dst by 2. This
|
~C!: When supplied a non-zero address, sets the SYSVARS+3e (see
|
||||||
shouldn't be used on regular memory, it will yield weird
|
impl.txt) override routine address. This should link dir-
|
||||||
results. Use it with C!* ialias pointing to a word-based target.
|
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
|
# Arithmetic / Bits
|
||||||
|
|
||||||
|
12
doc/impl.txt
12
doc/impl.txt
@ -159,10 +159,10 @@ offsets, but thankfully, there aren't many system variables.
|
|||||||
Here's a list of them:
|
Here's a list of them:
|
||||||
|
|
||||||
SYSVARS FUTURE USES +3c BLK(*
|
SYSVARS FUTURE USES +3c BLK(*
|
||||||
+02 CURRENT +3e FUTURE USES
|
+02 CURRENT +3e ~C!*
|
||||||
+04 HERE +40 FUTURE USES
|
+04 HERE +41 FUTURE USES
|
||||||
+06 C<? +42 FUTURE USES
|
+06 C<? +43 FUTURE USES
|
||||||
+08 C<* override +44 FUTURE USES
|
+08 C<* override +45 FUTURE USES
|
||||||
+0a NL ialias +51 CURRENTPTR
|
+0a NL ialias +51 CURRENTPTR
|
||||||
+0c C<* +53 EMIT ialias
|
+0c C<* +53 EMIT ialias
|
||||||
+0e WORDBUF +55 KEY ialias
|
+0e WORDBUF +55 KEY ialias
|
||||||
@ -193,6 +193,10 @@ for example), it can point elsewhere.
|
|||||||
|
|
||||||
BLK* "Disk blocks" in usage.txt.
|
BLK* "Disk blocks" in usage.txt.
|
||||||
|
|
||||||
|
~C!* if nonzero, contains a jump to assembly code that overrides
|
||||||
|
the routine that writes a byte to memory and then returns.
|
||||||
|
Register usage is arch-dependent, see boot code for details.
|
||||||
|
|
||||||
DRIVERS section is reserved for recipe-specific drivers.
|
DRIVERS section is reserved for recipe-specific drivers.
|
||||||
|
|
||||||
FUTURE USES section is unused for now.
|
FUTURE USES section is unused for now.
|
||||||
|
Loading…
Reference in New Issue
Block a user