From 2f83a0bea9da444e3d70569eba3d6847ca02be03 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 21 Sep 2018 21:59:17 +0200 Subject: ... --- forth/forth/avr/asmtest.fs | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 forth/forth/avr/asmtest.fs (limited to 'forth/forth/avr/asmtest.fs') diff --git a/forth/forth/avr/asmtest.fs b/forth/forth/avr/asmtest.fs new file mode 100644 index 0000000..7ec44ef --- /dev/null +++ b/forth/forth/avr/asmtest.fs @@ -0,0 +1,59 @@ +\ Some tests for the Atmega assembler +\ needs the assembler and see +-asmtest +marker -asmtest +: asmtest ( n1 n2 -- ) + = if ." OK" else ." ERROR" then cr ; + +#30 #28 mov, +flash here ram 2- @ $2fec asmtest \ Rd,Rr: + +#17 #15 ldi, +flash here ram 2- @ $e01f asmtest \ Rd,k: + +#17 $1234 lds, +flash here ram 4 - @+ swap @ u. u. \ Rd: 9110 1234 + +$09 constant Y+ +9 Y+ $31 ldd, + flash here ram 2 - @ $a899 asmtest + +$01 constant Z+ +9 Z+ $31 ldd, + flash here ram 2 - @ $a891 asmtest + +\ Leave true flag if zero flag is true +: testif0 + [ sez, ] \ Set zero flag + [ eq, if, ] \ if zero + true + [ else, ] \ else not zero + false + [ then, ] +; +testif0 . + +\ Leave true flag if zero flag is false +: testif1 + [ clz, ] \ Clear zero flag + [ eq, not, if, ] \ if not zero + true + [ else, ] \ else zero + false + [ then, ] +; +testif1 . + +\ Increment 24 bit value until result is zero +: testuntil + [ #16 #0 ldi, ] + [ #17 #0 ldi, ] + [ #18 #1 ldi, ] + [ begin, ] + [ #16 #6 add, ] \ R6 contains 1 + [ #17 #5 adc, ] \ R5 contains 0 + [ #18 #5 adc, ] + [ eq, until, ] \ until R18 is zero +; +testuntil + -- cgit v1.2.3