1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-27 17:18:05 +11:00
collapseos/blk/162
Virgil Dupras e31527f5ac Add word ROT>
There are many situations where it can be useful. Worth it.
2020-10-29 12:41:08 -04:00

14 lines
572 B
Plaintext

: aspfb! ( n a --, write word n to flash buffer addr a )
SWAP 256 /MOD ( a lo hi ) SWAP ROT ( hi lo a )
DUP ROT ( hi a a lo ) SWAP ( hi a lo a )
0 0x40 ( hi a lo a 0 0x40 ) _cmd DROP ( hi a )
0 0x48 _cmd DROP ;
: aspfp! ( page --, write buffer to page )
0 SWAP aspfpgsz @ * 256 /MOD ( 0 lsb msb )
0x4c _cmd DROP asprdy ;
: aspf@ ( page a -- n, read word from flash )
SWAP aspfpgsz @ * OR ( addr ) 256 /MOD ( lsb msb )
2DUP 0 ROT> ( lsb msb 0 lsb msb )
0x20 _cmd ( lsb msb low )
ROT> 0 ROT> ( low 0 lsb msb ) 0x28 _cmd 8 LSHIFT OR ;