: HEX,{ ( "hex-byte hex-byte ... }" ) \ Add bytes in hex to dictionary
BASE @ >R HEX
\ Loop over input
BEGIN
0.
PARSE-NAME \ Read while parse area has content and not }
DUP IF 2DUP S" }" COMPARE
ELSE FALSE THEN
WHILE
.S CR
\ Convert to number and add to dictionary
( 0 name-a name-u ) >NUMBER 2DROP D>S C,
REPEAT
R> BASE !
2DROP 2DROP ;
: iHEX,{ ( "hex-byte hex-byte ... }" ) \ Add bytes in hex to dictionary
BASE @ >R HEX
\ Loop over input
BEGIN
0.
PARSE-NAME \ Read while parse area has content and not }
DUP IF 2DUP S" }" COMPARE
ELSE FALSE THEN
WHILE
\ Convert to number and add to dictionary
( 0 name-a name-u ) >NUMBER 2DROP D>S POSTPONE LITERAL POSTPONE C,
REPEAT
R> BASE !
2DROP 2DROP ; IMMEDIATE
CREATE TEST
HEX,{ 00 20 30 40 50 10 20 30 10 20 }
HERE TEST - CONSTANT #TEST
: .TEST #TEST 0 ?DO TEST I + C@ . LOOP CR ;
.TEST
CREATE w
HEX,{ 01 02 }
w 10 DUMP
0 VALUE HERE$
: backup-here HERE TO HERE$ ;
: w->here w DP ! ;
: restore-here HERE$ DP ! ;
: mypatcher
backup-here w->here
iHEX,{ 03 00 00 00 05 00 00 00 }
restore-here
;
mypatcher
: .TEST2 10 0 ?DO w I + C@ . LOOP CR ;
.TEST2
OiBIRVgseyAoICJoZXgtYnl0ZSBoZXgtYnl0ZSAuLi4gfSIgKSBcIEFkZCBieXRlcyBpbiBoZXggdG8gZGljdGlvbmFyeQoJQkFTRSBAID5SIEhFWAoJXCBMb29wIG92ZXIgaW5wdXQKCUJFR0lOCgkJMC4KCQlQQVJTRS1OQU1FIFwgUmVhZCB3aGlsZSBwYXJzZSBhcmVhIGhhcyBjb250ZW50IGFuZCBub3QgfQoJCURVUCBJRiAyRFVQIFMiIH0iIENPTVBBUkUKCQkgICAgRUxTRSBGQUxTRSBUSEVOCgkJV0hJTEUKICAgICAgICAgICAgICAgIC5TIENSCgk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