This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

defining an asm block with parameters

After being "spoiled" by the power of macros and defines in asm, I was let down by the new inline __asm keyword. Want I need is a way to insert predefined blocks of assembly in the C code without having to worry about register assignments. For example: if I want to multiply to 16-bit values together to get a 32-bit result, all I need to do is

long fun_mult(short v1,short v2)
 { long i;
 __asm{MUL v1,v2};
 __asm{MOV word2 i,MDH};
 __asm(MOV word0 i,MDL);
 return(i);
 }
but the unnecessary overhead of calling a function to do such a simple operation ruins the savings of assembler to begin with.
Is there a way to create a macro in C that will be inserted inline and use the "correct registers"?
Something like
#define Mac_mult16x32(A,B,C) __asm{ ....}
 or a inline function
inline long fun_mult(register short v1,...

for later use inline

 Mac_mult16x32(local_i,local_v1,local_v2);
 or
 i = fun_mult(local_v1, local_v1);

(I have read App note 172)
Thank you,
Marty