arka7304
arka7304

Reputation: 25

Details avr assembler modifier lo8 are hard to find

Recently, while going through obdev's virtual usb drive for atmel avr, I found this expression

lo8(-usbrxbuf)

Unfortunately not much is given about lo8 modifier in the documents of avr-gcc. Can anybody here explain fully or give any link about it?

Upvotes: 0

Views: 3038

Answers (1)

turboscrew
turboscrew

Reputation: 676

Googling "lo8 avr" gives this as first hit.

lo8 This modifier allows you to use bits 0 through 7 of an address expression as 8 bit relocatable expression.

[edit]

Like here:

push    YH                  ;2 [2]
lds     YL, usbInputBufOffset;2 [4]
clr     YH                  ;1 [5]
subi    YL, lo8(-(usbRxBuf));1 [6]
sbci    YH, hi8(-(usbRxBuf));1 [7]

Looks as if it finds the buffer location address here. I don't know why the subtraction of negative base address from the offset instead of adding, but...

Oh, and I guess "relocatable" means "load time" here. That is, the value doesn't have to be known at assembly time, but it has to be known and constant at run time. Maybe the "lo8" and "hi8" create a relocation info type loader symbol (or expression) - much like segment address.

Upvotes: 1

Related Questions