mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 16:28:05 +11:00
Add words BIT@ and BIT!
This commit is contained in:
parent
244776a7eb
commit
a476773813
4
blk/050
4
blk/050
@ -4,6 +4,8 @@ Memory
|
||||
! n a -- Store n in address a
|
||||
? a -- Print value of addr a
|
||||
+! n a -- Increase value of addr a by n
|
||||
BIT@ b a -- f Get bit b from addr a.
|
||||
BIT! f b a -- Set bit b to f in addr 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 dec a.
|
||||
@ -11,6 +13,4 @@ C! c a -- Store byte c in address a
|
||||
C!+ c a -- a+1 Store byte c in a and inc a.
|
||||
C!- c a -- a-1 Store byte c in a and dec a.
|
||||
CURRENT -- a Set a to wordref of last added entry.
|
||||
CURRENT* -- a A pointer to active CURRENT*. Useful
|
||||
when we have multiple active dicts.
|
||||
(cont.)
|
||||
|
2
blk/051
2
blk/051
@ -1,3 +1,5 @@
|
||||
CURRENT* -- a A pointer to active CURRENT*. Useful
|
||||
when we have multiple active dicts.
|
||||
FILL a n b -- Fill n bytes at addr a with val b.
|
||||
HERE -- a Push HERE's address
|
||||
H@ -- a HERE @
|
||||
|
10
blk/404
10
blk/404
@ -4,9 +4,11 @@
|
||||
DUP NOT IF DROP 0x0c RAM+ @ THEN ( 0c == C<* )
|
||||
EXECUTE
|
||||
;
|
||||
|
||||
: , HERE @ ! HERE @ 2+ HERE ! ;
|
||||
|
||||
: C, HERE @ C! HERE @ 1+ HERE ! ;
|
||||
|
||||
|
||||
: BIT@ ( bit addr -- f ) C@ SWAP RSHIFT 0x01 AND ;
|
||||
: BIT! ( f bit addr -- )
|
||||
SWAP 0x01 SWAP LSHIFT ROT ( addr mask f )
|
||||
IF OVER C@ OR
|
||||
ELSE 0xff XOR OVER C@ AND THEN ( addr flg )
|
||||
SWAP C! ;
|
||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user