fork download
  1. : HEX,{ ( "hex-byte hex-byte ... }" ) \ Add bytes in hex to dictionary
  2. BASE @ >R HEX
  3. \ Loop over input
  4. BEGIN
  5. 0.
  6. PARSE-NAME \ Read while parse area has content and not }
  7. DUP IF 2DUP S" }" COMPARE
  8. ELSE FALSE THEN
  9. WHILE
  10. .S CR
  11. \ Convert to number and add to dictionary
  12. ( 0 name-a name-u ) >NUMBER 2DROP D>S C,
  13. REPEAT
  14.  
  15. R> BASE !
  16. 2DROP 2DROP ;
  17.  
  18. : iHEX,{ ( "hex-byte hex-byte ... }" ) \ Add bytes in hex to dictionary
  19. BASE @ >R HEX
  20. \ Loop over input
  21. BEGIN
  22. 0.
  23. PARSE-NAME \ Read while parse area has content and not }
  24. DUP IF 2DUP S" }" COMPARE
  25. ELSE FALSE THEN
  26. WHILE
  27. \ Convert to number and add to dictionary
  28. ( 0 name-a name-u ) >NUMBER 2DROP D>S POSTPONE LITERAL POSTPONE C,
  29. REPEAT
  30.  
  31. R> BASE !
  32.  
  33. 2DROP 2DROP ; IMMEDIATE
  34.  
  35. CREATE TEST
  36. HEX,{ 00 20 30 40 50 10 20 30 10 20 }
  37.  
  38. HERE TEST - CONSTANT #TEST
  39.  
  40. : .TEST #TEST 0 ?DO TEST I + C@ . LOOP CR ;
  41.  
  42. .TEST
  43.  
  44. CREATE w
  45. HEX,{ 01 02 }
  46.  
  47. w 10 DUMP
  48. 0 VALUE HERE$
  49. : backup-here HERE TO HERE$ ;
  50. : w->here w DP ! ;
  51. : restore-here HERE$ DP ! ;
  52.  
  53. : mypatcher
  54. backup-here w->here
  55. iHEX,{ 03 00 00 00 05 00 00 00 }
  56. restore-here
  57. ;
  58.  
  59. mypatcher
  60. : .TEST2 10 0 ?DO w I + C@ . LOOP CR ;
  61.  
  62. .TEST2
  63.  
Success #stdin #stdout 0s 4228KB
stdin
Standard input is empty
stdout
<4> 0 0 55EFA5C3B43E 2 
<4> 0 0 55EFA5C3B441 2 
<4> 0 0 55EFA5C3B444 2 
<4> 0 0 55EFA5C3B447 2 
<4> 0 0 55EFA5C3B44A 2 
<4> 0 0 55EFA5C3B44D 2 
<4> 0 0 55EFA5C3B450 2 
<4> 0 0 55EFA5C3B453 2 
<4> 0 0 55EFA5C3B456 2 
<4> 0 0 55EFA5C3B459 2 
0 32 48 64 80 16 32 48 16 32 
<4> 0 0 55EFA5C3B43E 2 
<4> 0 0 55EFA5C3B441 2 

2ADFD3C12990: 01 02 FF FF  2F BB FD FC - 5F 77                     ..../..._w
3 0 0 0 5 0 0 0 104 41