is a register in an AVR always 8 bits?

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

Reply to
Michael
Loading thread data ...

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)

an

Reply to
Brett

A macro does this for you. I use this macro to do

SetXPtr blahblahaddr

Rene

Brett wrote:

Reply to
Rene Tschaggelar

"Brett" wrote in news:bgl3vu$oph5v$ snipped-for-privacy@ID-184277.news.uni-berlin.de:

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!

Reply to
Michael

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
Principal Laser/Optical Technologist
Sandia National Laboratories CA USA
crcarle@sandia.gov -- NOTE: Remove "BOGUS" from email address to reply.
Reply to
Chris Carlen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.