L
L
Lerk2012-09-03 17:30:29
Arduino
Lerk, 2012-09-03 17:30:29

AVR inline asm. Need help or instructions

I'm trying to write on inline asm'e an analogue of the line:
PORTB = array[num];

Disassembly shows that the compiler spreads this matter like this:
LDD R24,Z+0
OUT 0x05,R24

where Z+num is the address of the array[num] element, and 0x05 is the address of PORTB.

Tried to smoke it , but it didn't work.
Please help :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Huseynov, 2012-09-03
@kibergus

What for? Do you know how to write it more efficiently?
You did not bring all the code into which the given C line was compiled, there is still a load of the array address into the Z register. These are two 8-bit registers. If I'm not mistaken, then r30 and r31.
Inline assembler can be written as
asm(
"LDD R24,Z+0\n"
"OUT 0x05,R24\n"
);
Will be pasted into the output file as is.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question