Hi,
this is just an EXPERIMENT. Words for flash XOR checksum (tested
with 1284p). 
Each i! writes a XOR checksum of the whole flash(!) to the variable
fxorsum. When after a crash something changes in flash the
checkflash shall show non zero. Not easy to simulate (as you cannot
use i!). The duration of fxor is 55ms at 25 MHz. Therefore let us
call it an experiment.

; word fxor ( flashsize-1 -- xorsum) flash XOR sum
; R( -- )
; Pito 21-9-2010
; returns XOR checksum of flash
VE_FXOR:
.dw $ff04
.db "fxor"
.dw VE_HEAD
.set VE_HEAD = VE_FXOR
XT_FXOR:
.dw PFA_FXOR
PFA_FXOR:
movw zl, tosl
ldi tosl, 0x00
ldi tosh, 0x00
loopfxor:
movw R14, zl
clr R18
lsl zl
rol zh
rol R18
out RAMPZ, R18
elpm R16, Z+
elpm R17, Z+
eor tosl, R16
eor tosh, R17
movw zl, R14
sbiw zl, 0x0001
sbiw zl, 0x0000
brne loopfxor
jmp_ DO_NEXT

\ i! with xorchecksum
\ pito 21-9-2010
\
\ XOR sum of flash in forth
: ffxor ( flashsize-1 -- ffxorsum )
0 swap begin 
dup i@ rot xor swap 1-
dup 0 = until drop ; 

variable fxorsum

: ixorsum! (i!) $ffff fxor fxorsum ! ;

' ixorsum! is i!

: checkflash $ffff fxor fxorsum @ - u. ;

*******************************************************
Ex:

> $ffff ffxor u.
A3F9  ok
> $ffff fxor u.
A3F9  ok
> fxorsum @ u.
6607  ok
> variable hello
ok
> $ffff ffxor u.
55B3  ok
> $ffff fxor u.
55B3  ok
> fxorsum @ u.
55B3  ok
> variable amforth
ok
> $ffff ffxor u.
2366  ok
> $ffff fxor u.
2366  ok
> fxorsum @ u.
2366  ok
> 
ok
> : checkflash $ffff fxor fxorsum @ - u. ;
ok
> checkflash
0  ok
> $ffff ffxor u.
B6E3  ok
> $ffff fxor u.
B6E3  ok
> fxorsum @ u.
B6E3  ok
> 




------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Amforth-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to