aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/msp430/words/cmove.asm
diff options
context:
space:
mode:
Diffstat (limited to 'amforth-6.5/msp430/words/cmove.asm')
-rw-r--r--amforth-6.5/msp430/words/cmove.asm16
1 files changed, 16 insertions, 0 deletions
diff --git a/amforth-6.5/msp430/words/cmove.asm b/amforth-6.5/msp430/words/cmove.asm
new file mode 100644
index 0000000..a25b255
--- /dev/null
+++ b/amforth-6.5/msp430/words/cmove.asm
@@ -0,0 +1,16 @@
+;X CMOVE c-addr1 c-addr2 u -- move from bottom
+; as defined in the ANSI optional String word set
+; On byte machines, CMOVE and CMOVE> are logical
+; factors of MOVE. They are easy to implement on
+; CPUs which have a block-move instruction.
+ CODEHEADER(XT_CMOVE,5,"cmove")
+ MOV @PSP+,W ; dest adrs
+ MOV @PSP+,X ; src adrs
+ CMP #0,TOS
+ JZ CMOVE_X
+CMOVE_1: MOV.B @X+,0(W) ; copy byte
+ ADD #1,W
+ SUB #1,TOS
+ JNZ CMOVE_1
+CMOVE_X: MOV @PSP+,TOS ; pop new TOS
+ NEXT