Skip to content

Commit 2363417

Browse files
committed
add X_ldiw macro
1 parent 3efe21a commit 2363417

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/macros.inc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
1+
; Ralph Doncaster public domain AVR assembler macros
12

23
.macro GLABEL name
34
.global \name
45
\name:
56
.endm
7+
8+
; in/out require an io register at address < 0x40
9+
.macro LOAD rd, ioreg
10+
.if \ioreg > 0x3F
11+
lds \rd, \ioreg
12+
.else
13+
in \rd, \ioreg
14+
.endif
15+
.endm
16+
17+
.macro STORE ioreg, rr
18+
.if \ioreg > 0x3F
19+
sts \ioreg, \rr
20+
.else
21+
out \ioreg, \rr
22+
.endif
23+
.endm
24+
25+
; example: X_ldiw 24, 12345
26+
.macro X_ldiw rd, K
27+
ldi \rd, lo8(\K)
28+
ldi (\rd)+1, hi8(\K)
29+
.endm
30+

src/millis.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
GLABEL millis_impl
1111
ldi ZL, lo8(t0_millis)
1212
ldi ZH, hi8(t0_millis)
13+
; X_ldiw 30, t0_millis ; Z = t0_millis
1314
_reload:
1415
ld r22, Z
1516
ldd r23, Z+1

0 commit comments

Comments
 (0)