R
robin.pain
Inlining assembler in a *.c file:-
Both
__asm("nop \n")
and
__asm("nop")
work
I have abandonned using __asm() it because it only seems to accept a
literal string. Trying to pass it an <unsigned char*> as the manual
suggests fails with a syntax error. Also as a last resort I tried
this:-
__asm ("ldaa SC1SR1")
__asm ("std SC1DRH")
but it failed with a "unknown variable or function identifier".
Despite the proceeding:-
#include <r812a4.h>
That contains SC1SR1 etc. It only works if you avoid labels entirely
e.g.
__asm ("ldaa 0xCC")
__asm ("std 0xCD")
Which is asking for it! "I didn't get where I am today by..." as the
famous Rigsby used to say.
What I have opted for is to add a *.s33 file to the project containing
the assembler [and my beloved macro that I originally intended to pass
to the __asm ( ) ]:-
//****************.s33 file *********************
$equates.equ
RSEG RCODE //Root-Code: assemble in common or
shared rom
public init_sci_and_send_a_percent
....
init_sci_and_send_a_percent
ldaa SC1SR1 //step 1 of clear pending data
interrupts
std SC1DRH //step 2 of clear pending data
interrupts
aux_tx '%' //send an % char from RS232
rtc
END
//****************end of *.s33 file***************
And then calling if from the *.c file
//****************.c file ************************
extern init_sci_and_send_a_percent
....
init_sci_and_send_a_percent();
//**************end of *.c file*******************
It is easy to mix and match *.s33 and *.c files but only the crudest
inlining is possible and only by breaking the one definition rule. At
the very least we should be able to inline a macro that's the whole
point!
Robin
Both
__asm("nop \n")
and
__asm("nop")
work
I have abandonned using __asm() it because it only seems to accept a
literal string. Trying to pass it an <unsigned char*> as the manual
suggests fails with a syntax error. Also as a last resort I tried
this:-
__asm ("ldaa SC1SR1")
__asm ("std SC1DRH")
but it failed with a "unknown variable or function identifier".
Despite the proceeding:-
#include <r812a4.h>
That contains SC1SR1 etc. It only works if you avoid labels entirely
e.g.
__asm ("ldaa 0xCC")
__asm ("std 0xCD")
Which is asking for it! "I didn't get where I am today by..." as the
famous Rigsby used to say.
What I have opted for is to add a *.s33 file to the project containing
the assembler [and my beloved macro that I originally intended to pass
to the __asm ( ) ]:-
//****************.s33 file *********************
$equates.equ
RSEG RCODE //Root-Code: assemble in common or
shared rom
public init_sci_and_send_a_percent
....
init_sci_and_send_a_percent
ldaa SC1SR1 //step 1 of clear pending data
interrupts
std SC1DRH //step 2 of clear pending data
interrupts
aux_tx '%' //send an % char from RS232
rtc
END
//****************end of *.s33 file***************
And then calling if from the *.c file
//****************.c file ************************
extern init_sci_and_send_a_percent
....
init_sci_and_send_a_percent();
//**************end of *.c file*******************
It is easy to mix and match *.s33 and *.c files but only the crudest
inlining is possible and only by breaking the one definition rule. At
the very least we should be able to inline a macro that's the whole
point!
Robin