1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-05 08:40:54 +11:00

Add words BIT@ and BIT!

This commit is contained in:
Virgil Dupras 2020-05-10 08:40:49 -04:00
parent 244776a7eb
commit a476773813
4 changed files with 10 additions and 6 deletions

View File

@ -4,6 +4,8 @@ Memory
! n a -- Store n in address a ! n a -- Store n in address a
? 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
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 -- 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.
@ -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 inc a.
C!- c a -- a-1 Store byte c in a and dec 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 Set a to wordref of last added entry.
CURRENT* -- a A pointer to active CURRENT*. Useful
when we have multiple active dicts.
(cont.) (cont.)

View File

@ -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. FILL a n b -- Fill n bytes at addr a with val b.
HERE -- a Push HERE's address HERE -- a Push HERE's address
H@ -- a HERE @ H@ -- a HERE @

10
blk/404
View File

@ -4,9 +4,11 @@
DUP NOT IF DROP 0x0c RAM+ @ THEN ( 0c == C<* ) DUP NOT IF DROP 0x0c RAM+ @ THEN ( 0c == C<* )
EXECUTE EXECUTE
; ;
: , HERE @ ! HERE @ 2+ HERE ! ; : , HERE @ ! HERE @ 2+ HERE ! ;
: C, HERE @ C! HERE @ 1+ 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! ;

Binary file not shown.