Reputation: 21730
I am trying to accomplish:
LABEL:
....
subi r18, LABEL
I need to subtract address of a label from a register. How do I do that?
Upvotes: 0
Views: 1017
Reputation: 21730
subi r16, pm_lo8(LABEL)
sbci r17, pm_hi8(LABEL)
as answered on avrfreaks:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=857982#857982
reference document:
http://sourceware.org/binutils/docs-2.21/as/AVR_002dModifiers.html#AVR_002dModifiers
Upvotes: 2
Reputation: 30460
Note: I'm not that familiar with AVR assembler, this is just what I could gauge from reading a few webpages. I'm also assuming that your addresses are 16-bit.
; Address you wish to subtract the label from in R16 (low):R17 (high)
SUBI R16, LOW(LABEL)
SBCI R17, HIGH(LABEL) ; Omit this part if you have < 256 Bytes of ram
Upvotes: 1