--- organix80 <organix@hetnet.nl> wrote:
> Is it possible to use 16-bit constant labels in
> WinAVR inline assembly?
>
> Normally, in a assembly program, you can do:
>
> lds r16, 0x0412 (just a example)
>
> In mixed C/asm, some variables are stored in SRAM by
> the compiler. How
> to read them using 'lds' and 'sts' in inline
> assembly?
>
> asm volatile(" ... "
> : (inputs)
> : (outputs)
> );
>
> It seems that there is no 16-bit integer constant in
> the list. (see
> table on
>
ttp://www.scienceprog.com/how-to-use-inline-asm-using-winavr)
>
> The constrains that could be used for addressing,
> are using the X, Y
> or Z pointer, but this requires a lot more
> instructions then just
> 'lds' or 'sts'.
>
> Does anyone know the method and constrains that must
> be used to read C
> SRAM variables using 'lds' and 'sts' in inline
> assembly?
>
> Regards Laurens
>
>
>
this is an example of accessing such things in C using
inline assembly:
/* a simple program to show the usage of assembler
code in your c- programs 8/00 Leitner Harald */
#include<io.h>
uint8_t val1, val2;
int main(void)
{
outp(0xff,DDRB); /* use all pins on PortB for output
*/
val1 = 3;
val2 = 4;
asm volatile
(
"LDS R30,val1\n" /* start of the asm part*/
LDS R31,val2\n"
ADD R30,R31\n"
RJMP do\n" /* definition of jump labels */
LDI R30,0xFF\n"
do:STS val1,R30\n"
::);
outp(~val1,PORTB); /* write result of val1+val2 to
Port */
for (;;){}
}
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhostingMessage
Re: [AVR-Chat] Using (16-bit) labels in WinAVR inline asm
2007-07-21 by Reza
Attachments
- No local attachments were found for this message.