aboutsummaryrefslogtreecommitdiff
path: root/forth/forth/avr/asmtest.fs
blob: 7ec44ef564226a6b11d846459e68f1c889c3a746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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