Quellcode durchsuchen

Add words BIT@ and BIT!

pull/102/head
Virgil Dupras vor 4 Jahren
Ursprung
Commit
a476773813
4 geänderte Dateien mit 10 neuen und 6 gelöschten Zeilen
  1. +2
    -2
      blk/050
  2. +2
    -0
      blk/051
  3. +6
    -4
      blk/404
  4. BIN
      emul/forth.bin

+ 2
- 2
blk/050 Datei anzeigen

@@ -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
- 0
blk/051 Datei anzeigen

@@ -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 @


+ 6
- 4
blk/404 Datei anzeigen

@@ -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 Datei anzeigen


Laden…
Abbrechen
Speichern