is a register in an AVR always 8 bits?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi - a register is just flash storage (or some other volatile memory) in an
AVR, right? Are registers always 8 bits long? Thanks!

Re: is a register in an AVR always 8 bits?
A register is sram, and they are all 8 bits, however the specials registers
and some IO ports extend over multiple registers or IO ports.

EX: The X, Y, or Z memory pointers. Those 16-bit values exist over two
registers.

So often you end up with code like:
ldi    XL, LOW(blahblahaddr)
ldi    XH, HIGH(blahblahaddr)

Quoted text here. Click to load it
an



Re: is a register in an AVR always 8 bits?
A macro does this for you. I use this macro to do

SetXPtr  blahblahaddr

Rene

Brett wrote:
Quoted text here. Click to load it


Re: is a register in an AVR always 8 bits?

Quoted text here. Click to load it

Oh - so you're saying tha the LOW() macro returns the first byte of a 2
byte register and the HIGH() macro returns the second byte of a 2 byte
macro? I had seen those in use and had been really really confused by
them!

Re: is a register in an AVR always 8 bits?
Quoted text here. Click to load it


No, the registers are *always* 8 bits.

The instructions above are "load immediate" which means to load a
constant value into a register.  The LOW and HIGH macros return the low
and hogh bytes respectively of the constant.

Thus, the XL register which is 8 bits, is loaded with the low 8 bits of
the constant "blahblahaddr".  Likewise for the XH register.

*You* see the X pointer register as two 8 bit pieces when loading it.


Good day!



--
_______________________________________________________________________
Christopher R. Carlen
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline