commit 838967f90e863f5dc5d64da8a0f108cd8f234829
parent 2fc31b6c3c82f0f631dfd0056f9fc996c5757355
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Wed, 24 May 2023 12:09:32 -0400
rpi: add "word" routine
Does it look like I'm tumbling forth?
Diffstat:
3 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/fs/asm/arm.fs b/fs/asm/arm.fs
@@ -28,11 +28,11 @@
8 cond hi) 9 cond ls) 10 cond ge) 11 cond lt)
12 cond gt) 13 cond le)
-: op doer , does> @ 21 lshift $e0000000 or ;
-0 op and) 1 op eor) 2 op sub) 3 op rsb)
-4 op add) 5 op adc) 6 op sbc) 7 op rsc)
-8 op tst) 9 op teq) 10 op cmp) 11 op cmn)
-12 op orr) 13 op mov) 14 op bic) 15 op mvn)
+: op doer , does> @ 20 lshift $e0000000 or ;
+$00 op and) $02 op eor) $04 op sub) $06 op rsb)
+$08 op add) $0a op adc) $0c op sbc) $0e op rsc)
+$11 op tst) $13 op teq) $15 op cmp) $17 op cmn)
+$18 op orr) $1a op mov) $1c op bic) $1e op mvn)
: f) $00100000 or ;
diff --git a/fs/doc/asm/arm.txt b/fs/doc/asm/arm.txt
@@ -58,6 +58,8 @@ rn) shouldn't be used with mov) and mvn)
To have the operation set the CPSR flags, you can use the word f) which sets the
"S" bit of the instruction.
+tst) teq) cmp) and cmn) have an implied "f)".
+
## Single Data Transfer
The str) and ldr) operations only use rd) and rn), with rd) being the register
diff --git a/fs/xcomp/arm/rpi/kernel.fs b/fs/xcomp/arm/rpi/kernel.fs
@@ -15,12 +15,14 @@ $30 const UART0_CR
$38 const UART0_IMSC
$44 const UART0_ICR
+$10000 const CURWORD
+
: delay, ( ncycles -- )
mov) r0 rd) swap ( ncycles ) i) ,)
pc sub) r0 rd) r0 rn) 1 i) f) ,) ( pc ) abs>rel b) ne) ,) ;
: values ( n -- ) for 0 value next ;
-4 values lblemit lblkey lblrtype lblmsg
+5 values lblemit lblkey lblrtype lblword lblmsg
$8000 to binstart
0 align4 here to org
@@ -28,13 +30,13 @@ forward b) ,)
pc to lblmsg ," Hello World!" 0 align4
pc to lblemit \ r0=char
ldr) r3 rd) r7 rn) UART0_FR +i) ,)
- tst) r3 rn) $20 i) f) ,)
+ tst) r3 rn) $20 i) ,)
lblemit abs>rel b) ne) ,)
str) r0 rd) r7 rn) UART0_DR +i) ,)
lret,
pc to lblkey \ r0=char
ldr) r3 rd) r7 rn) UART0_FR +i) ,)
- tst) r3 rn) $10 i) f) ,)
+ tst) r3 rn) $10 i) ,)
lblkey abs>rel b) ne) ,)
ldr) r0 rd) r7 rn) UART0_DR +i) 8b) ,)
lret,
@@ -44,6 +46,21 @@ pc to lblrtype \ r1=addr r2=len
sub) r2 rd) r2 rn) 1 i) f) ,)
lblrtype abs>rel b) ne) ,)
lret,
+pc to lblword \ r2=len, word in CURWORD
+ pc
+ lblkey abscall,
+ cmp) r0 rn) SPC i) ,)
+ ( pc ) abs>rel b) ls) ,) \ r0=first non-ws
+ mov) r2 rd) 0 i) ,)
+ mov) r1 rd) CURWORD i) ,)
+ pc
+ add) r2 rd) r2 rn) 1 i) ,)
+ str) r0 rd) r1 rn) 8b) 1 +i) post) ,)
+ lblkey abscall,
+ cmp) r0 rn) SPC i) ,)
+ ( pc ) abs>rel b) hi) ,)
+ lret,
+
forward!
mov) rSP rd) binstart i) ,)
mov) r9 rd) MMIO_BASE i) ,) \ r9 = MMIO_BASE
@@ -87,6 +104,7 @@ mov) r2 rd) 12 i) ,)
lblrtype abs>rel bl) ,)
pc
- lblkey abs>rel bl) ,)
- lblemit abs>rel bl) ,)
+ lblword abs>rel bl) ,)
+ mov) r1 rd) CURWORD i) ,)
+ lblrtype abs>rel bl) ,)
abs>rel b) ,)