M fs/xcomp/arm/rpi/kernel.fs => fs/xcomp/arm/rpi/kernel.fs +39 -0
@@ 631,6 631,45 @@ pc to L2 ( a -- a ) \ r2=base instr
sub) rTOP rdn) 4 i) ,)
exit,
+xcode branchC, ( a cond -- a )
+ mov) r2 rd) $0a000000 i) ,)
+ orr) r2 rdn) rTOP rm) ,)
+ xdrop,
+ L2 abs>rel b) ,)
+
+pc mov) rPC rd) rA rm) ,)
+xcode branchA,
+ ( pc ) r0 pc@>reg, lbldwrite abs>rel b) ,)
+
+xcode branch! ( tgt a -- )
+ r1 ppop, \ r1=tgt
+ sub) r0 rd) r1 rn) rTOP rm) ,) \ r0=displacement
+ mov) r0 rd) r0 rm) 2 lsr) ,)
+ sub) r0 rdn) 2 i) ,)
+ bic) r0 rn) $ff000000 i) ,) \ r0=24-bit offset
+ ldr) r1 rd) rTOP rn) ,)
+ and) r1 rdn) $ff000000 i) ,)
+ orr) r0 rdn) r1 rm) ,)
+ str) r0 rd) rTOP rn) ,)
+ xdrop, exit,
+
+pc cmp) rTOP rn) 0 i) ,)
+xcode W=0>Z,
+ ( pc ) r0 pc@>reg, lbldwrite abs>rel b) ,)
+
+pc cmp) rA rn) 0 i) ,)
+xcode A=0>Z,
+ ( pc ) r0 pc@>reg, lbldwrite abs>rel b) ,)
+
+pc mov) rTOP rd) 0 i) ,) add) z) ( 0 cond ) rTOP rdn) 1 i) ,)
+xcode C>W, ( cond -- )
+ dup ( pc ) r0 pc@>reg,
+ pushret, lbldwrite abs>rel bl) ,) popret,
+ ( pc ) 4 + r0 pc@>reg,
+ orr) r0 rdn) rTOP rm) ,)
+ xdrop,
+ lbldwrite abs>rel b) ,)
+
pc xdup,
xcode dup,
( pc ) r0 pc@>reg, lbldwrite abs>rel b) ,)
M fs/xcomp/bootlo.fs => fs/xcomp/bootlo.fs +1 -1
@@ 73,7 73,7 @@ code 1- -1 W+n, exit,
code execute W>A, drop, branchA,
code not W=0>Z, Z) C>W, exit,
code bool W=0>Z, NZ) C>W, exit,
-: if 0 W>A, drop, A=0>Z, Z) branchC, ; immediate
+: if W>A, drop, A=0>Z, 0 Z) branchC, ; immediate
: ahead 0 branch, ; immediate
: then HERE @ swap branch! ; immediate
code ?dup W=0>Z, 0 Z) branchC, dup, then exit,
M fs/xcomp/rpiboot.fs => fs/xcomp/rpiboot.fs +28 -2
@@ 70,5 70,31 @@ code 1- -1 W+n, exit,
: , HERE @!+ ; :16b HERE 16b @!+ ; :8b HERE 8b @!+ ; : c, 8b , ;
-uartinit prompt interactive!
-
+code execute W>A, drop, branchA,
+code not W=0>Z, Z) C>W, exit,
+code bool W=0>Z, NZ) C>W, exit,
+: if W>A, drop, A=0>Z, 0 Z) branchC, ; immediate
+: ahead 0 branch, ; immediate
+: then HERE @ swap branch! ; immediate
+code ?dup W=0>Z, 0 Z) branchC, dup, then exit,
+: ' word sysdict @ find dup not if (wnf) then ;
+: ['] ' litn ; immediate
+: compile ' litn ['] execute, execute, ; immediate
+: [compile] ' execute, ; immediate
+: allot HERE +! ;
+: else [compile] ahead HERE @ rot branch! ; immediate
+: begin HERE @ ; immediate
+: again branch, drop ; immediate
+: until W>A, drop, A=0>Z, Z) branchC, drop ; immediate
+: = - not ;
+: \ begin in< $0a = until ; immediate
+uartinit \ see the (wnf) if comment is mishandled
+\ hello, this is a comment!
+\ This type of comment won't work in UART because we don't get a LF, only a CR
+: exit exit, ; immediate
+: ( begin
+ word dup c@ 1 = if
+ 1+ c@ ')' = if exit then else drop then
+ again ; immediate
+\ TODO: this comment type doesn't work, debug
+prompt interactive!