Go Down

Topic: Watchdog ISR in assembly language (Read 8 times) previous topic - next topic


Feb 15, 2011, 01:16 am Last Edit: Feb 15, 2011, 02:24 am by stimmer Reason: 1
Can't you use the assembler .include directive? This works for me in Linux (I don't know about Windows).

Code: [Select]
asm (".include \"/full/path/to/sketch/asm.h\" \n");

extern "C" int func();

void setup()

void loop()

Code: [Select]
.section .text

.equ elo, 105
.equ ehi, 122

.global func
 ldi r24,elo
 ldi r25,ehi

I use a .h file so the IDE doesn't complain, it's a bit of a hack. You seem to have to use an absolute path to .include, and you have to remember to save it in the IDE each time you change it before compiling.


asm("#define   SREG   0x3f\n");
asm("    in       r16,SREG\n");  // fails with "Error: constant value required"
asm("    in       r16,0x3f\n");  // works

I tried with and without \n, no difference. I often wondered about the \n in these assembler examples, it's the sort of thing you do when generating HTML code that has to be read by a human but you wouldn't expect it to be required here.

I did the same with the small exception that I don't have python installed  :), I'll go and get it.

That approach produced 964

at com.oroinc.text.regex.Perl5Matcher._match(Perl5Matcher.java)


However I noticed your .equ syntax is different

asm(".equ SREG,0x3f\n");
asm("    in       r16,SREG\n");  // this works


asm(".equ r_temp1,r16\n");
asm("    push    r_temp\n"); // this doesn't work,  Error: register name or number from 0 to 31 required
asm("    in    r_temp,SREG\n"); // same error

Is this the ASM equivelant of "lvalue required"?

Anyway that's where I left it at 2AM last night. I'm back on deck now so will continue with this.

Rob Gray aka the GRAYnomad www.robgray.com


I don't know if you can properly use .equ or = to rename registers.

But it just happens to work under certain circumstances. In particular, don't make the first letter of the symbol 'r' and omit the 'r' from the register. ie:

.equ q_temp1,16

which is the same as

q_temp1 = 16

should 'work', at least for now.


I'll have to check the mechanics of having assembler included in your sketch when I'm at home with the source code.
I thought you could add a .S tab to your sketch just the way you can add .h, .c, or .cpp modules.  It may have to be capitalized...


Huh.  It looks like the "Compiler" part of the IDE understands .S files, but the editor refuses to add such files to the sketch, or pass them to the compiler.  Hmmph.

Go Up