I'm looking into ATtiny13 register summary, and I've googled quite a bit but failed to learn which registers can I use for passing values etc. For example - is PORTB register, with address 0x18 also called R24?
Looking into compiled code, I see that R24 is used by C++ compiler for passing argument to a function, so I wouldn't say so.
But then, how do you guys know which Rxx to use? How are these rnn mapped to real register addresses? Do they represent only "Reserved" registers? ATtiny13 has 31 of those.
No, they are not the same. All of the registers with names other than rxx are I/O registers, and they should not be used for passing values because they tell the peripherals to do things.
See chapter 5 of the datasheet - it is explained there.
If you're mixing c and assembly, there's a section of the avr-libc docs that has some good information written plainly on which registers you have to treat specially.
In ATtiny13A datasheet, page 10, Figure 4-2 shows that R0 address is 0x00, R1 address is 0x01, R2 address is 0x02 etc. I am still totally confused about which are general purpose registers in ATtiny13. There is no table with each register nicely named R1...R31, PORTB, SPL, DDRB, etc. along with addresses, so I can see which register I can freely use and I want to use it by address, not like Rxx.
Here they say that R24 equals 0x18, could someone please reveal this mystery to me, what are exact addresses of general purpose registers in ATtiny13 I can use for variables? I've edited this image from tiny13 datasheet, is this correct?
I am trying to learn which registers I can freely use for passing variables etc. But not that Rxx thing, just simply 0xnn addresses of these registers.
I want to know because I want to write some sketches in assembly in order to save any space I possibly can save, to fit it into 1024 bytes. I want to call registers by their address, not by some arbitrary names like Rxx. I want to know which registers I am using.
TomGeorge:
Hi,
R24 is decimal of 0x18, 0x18 is a hex value. that is what the x means.
Tom...
Yeah, I know that, and 0x18 happens to be PORTB register, and DrAzzy upthere said that they are not the same so I am confused. I've found AVR binary opcodes here: Using as: AVR Opcodes and I took a look into my compiled code and found a few random PUSH instructions, to determine register addresses, and this is what I found:
Image is conspicously titled "Register summary", and addresses start with 0x00 and end with 0x3F.
Now I am confused even more! How does "ldi 0x03, 0x10" produce more code than "ldi r3, 0x10"?
I've come here seeking some help. Namely, what is address of register r0? What is address of register r1? What is address of register r10? What is address of register r20, etc?
losmi:
...addresses start with 0x00 and end with 0x3F...
I/O addresses. For which there are I/O machine instructions. Instructions that operate exclusively in the I/O address space.
I/O addresses are mapped to SRAM addresses. Which allow those some locations to be accessed using SRAM machine instructions. But the I/O addresses are not the same as SRAM addresses.
Which is also true for the general purpose registers.