aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/avr8/words/compare.asm
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-08-19 12:15:28 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-08-19 12:15:28 +0200
commit67d25d837ac55f28a366c0a3b262e439a6e75fc3 (patch)
treedf7715c7724c5935ab87c807f3b8b4ef529315e3 /amforth-6.5/avr8/words/compare.asm
parente0d6784e89dba33226c0edb815bb974486fa7c48 (diff)
Add AmForth
Diffstat (limited to 'amforth-6.5/avr8/words/compare.asm')
-rw-r--r--amforth-6.5/avr8/words/compare.asm47
1 files changed, 47 insertions, 0 deletions
diff --git a/amforth-6.5/avr8/words/compare.asm b/amforth-6.5/avr8/words/compare.asm
new file mode 100644
index 0000000..0a33f47
--- /dev/null
+++ b/amforth-6.5/avr8/words/compare.asm
@@ -0,0 +1,47 @@
+; ( r-addr r-len f-addr f-len -- f)
+; String
+; compares two strings in RAM
+VE_COMPARE:
+ .dw $ff07
+ .db "compare",0
+ .dw VE_HEAD
+ .set VE_HEAD = VE_COMPARE
+XT_COMPARE:
+ .dw PFA_COMPARE
+PFA_COMPARE:
+ push xh
+ push xl
+ movw temp0, tosl
+ loadtos
+ movw xl, tosl
+ loadtos
+ movw temp2, tosl
+ loadtos
+ movw zl, tosl
+PFA_COMPARE_LOOP:
+ ld temp4, X+
+ ld temp5, Z+
+ cp temp4, temp5
+ brne PFA_COMPARE_NOTEQUAL
+ dec temp0
+ breq PFA_COMPARE_ENDREACHED2
+ dec temp2
+ brne PFA_COMPARE_LOOP
+ rjmp PFA_COMPARE_ENDREACHED
+PFA_COMPARE_ENDREACHED2:
+ dec temp2
+PFA_COMPARE_ENDREACHED:
+ or temp0, temp2
+ brne PFA_COMPARE_CHECKLASTCHAR
+ clr tosl
+ rjmp PFA_COMPARE_DONE
+PFA_COMPARE_CHECKLASTCHAR:
+PFA_COMPARE_NOTEQUAL:
+ ser tosl
+ rjmp PFA_COMPARE_DONE
+
+PFA_COMPARE_DONE:
+ mov tosh, tosl
+ pop xl
+ pop xh
+ jmp_ DO_NEXT