Hi - a register is just flash storage (or some other volatile memory) in an AVR, right? Are registers always 8 bits long? Thanks!
is a register in an AVR always 8 bits?
Aug 03, 2003
4 Replies
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
A macro does this for you. I use this macro to do
SetXPtr blahblahaddr
Rene
Brett wrote:
"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!
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.
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required