Loading b16.asm +4 −3 Original line number Diff line number Diff line #! /usr/bin/gforth b16-asm.fs : reset \ label reset fw jmp \ jump forward to boot ' boot jmp \ jump forward to boot : stack \ stack test 1 #c 2 #c 3 # \ fill stack with 1 2 3 4 5 6 7 8 9 A B 4 # 5 #c 6 #c Loading Loading @@ -52,11 +52,12 @@ 0 # com cIF drop 5 # + THEN 0 #c 0 #c + -cIF drop 6 # + THEN ; \ return to caller : boot THEN \ resolve forward jump from reset : boot \ resolve forward jump from reset stack \ call stack test alu \ call ALU test $1234 # $5678 # mul \ multiply 1234 with 5678 (hex) $789a # div drop drop \ divide by 789A, drop results jumps -jumps \ call jump tests BEGIN jmp ; \ endless loop ; \ endless loop .end \ end of test program .hex b16.fs +29 −3 Original line number Diff line number Diff line Loading @@ -274,9 +274,35 @@ Forth : .end inst, ; : macro: : ; : end-macro postpone ; ; immediate : : Create inst, IP @ , DOES> @ inst, 1 jmp, ; : | Create inst, IP @ , DOES> @ ; : ' ' >body @ ; \ label handling : :-does DOES> @ inst, 1 jmp, ; : |-does DOES> @ ; : label-resolve ( addr -- ) cell+ @ BEGIN dup -1 <> WHILE dup >r @ $FC00 [ b16-asm ] THEN [ Forth ] r> cell+ @ REPEAT drop ; : ?Create >in @ >r name find IF rdrop lastcfa ! inst, IP @ lastcfa @ >body ! lastcfa @ >body label-resolve lastcfa @ >body cell+ off ELSE drop r> >in ! Create inst, IP @ , 0 , THEN ; : : ?Create :-does ; : | ?Create |-does ; : ' ( "name" -- addr ) >in @ >r name find IF >body dup @ swap cell+ dup @ IF here IP @ , over @ , swap ! IP @ $FC00 and ELSE drop THEN rdrop ELSE drop r> >in ! Create 0 , here cell+ , IP @ $FC00 and dup , -1 , |-does THEN ; $00 inst nop $01 2 insts3 exec goto Loading Loading
b16.asm +4 −3 Original line number Diff line number Diff line #! /usr/bin/gforth b16-asm.fs : reset \ label reset fw jmp \ jump forward to boot ' boot jmp \ jump forward to boot : stack \ stack test 1 #c 2 #c 3 # \ fill stack with 1 2 3 4 5 6 7 8 9 A B 4 # 5 #c 6 #c Loading Loading @@ -52,11 +52,12 @@ 0 # com cIF drop 5 # + THEN 0 #c 0 #c + -cIF drop 6 # + THEN ; \ return to caller : boot THEN \ resolve forward jump from reset : boot \ resolve forward jump from reset stack \ call stack test alu \ call ALU test $1234 # $5678 # mul \ multiply 1234 with 5678 (hex) $789a # div drop drop \ divide by 789A, drop results jumps -jumps \ call jump tests BEGIN jmp ; \ endless loop ; \ endless loop .end \ end of test program .hex
b16.fs +29 −3 Original line number Diff line number Diff line Loading @@ -274,9 +274,35 @@ Forth : .end inst, ; : macro: : ; : end-macro postpone ; ; immediate : : Create inst, IP @ , DOES> @ inst, 1 jmp, ; : | Create inst, IP @ , DOES> @ ; : ' ' >body @ ; \ label handling : :-does DOES> @ inst, 1 jmp, ; : |-does DOES> @ ; : label-resolve ( addr -- ) cell+ @ BEGIN dup -1 <> WHILE dup >r @ $FC00 [ b16-asm ] THEN [ Forth ] r> cell+ @ REPEAT drop ; : ?Create >in @ >r name find IF rdrop lastcfa ! inst, IP @ lastcfa @ >body ! lastcfa @ >body label-resolve lastcfa @ >body cell+ off ELSE drop r> >in ! Create inst, IP @ , 0 , THEN ; : : ?Create :-does ; : | ?Create |-does ; : ' ( "name" -- addr ) >in @ >r name find IF >body dup @ swap cell+ dup @ IF here IP @ , over @ , swap ! IP @ $FC00 and ELSE drop THEN rdrop ELSE drop r> >in ! Create 0 , here cell+ , IP @ $FC00 and dup , -1 , |-does THEN ; $00 inst nop $01 2 insts3 exec goto Loading