Page 1 of 1

calling a macro from assembler

Posted: Mon Oct 03, 2011 12:23 pm
by Dave S
Hi,

I am having problems calling a macro from within asm. The help file says to call _FCM_MACRO() but the compiler doesn't like it.

asm
{
call _FCM_MACRO()
}

Any ideas on what I'm doing wrong please? (the name MACRO is just an example).

Thanks,

Dave.

Re: calling a macro from assembler

Posted: Mon Oct 03, 2011 9:43 pm
by JonnyW
Hi Dave. After a bit of experimentation the syntax seems to be:

Code: Select all

  asm
  {
    call FCM_macro
  }
This is case sensitive (the macro was created lower case) and does not have closing brackets. I am not familiar with PIC assembly but Im assuming you will have to push each argument you need first. You can view the C code and cut-paste the exact definition from there.
grab.png
Snapshot of icon
(11.87 KiB) Downloaded 2245 times
Out of curiosity, may I as what you are doing to require calling a macro from assembly?

Cheers,

Jonny

Re: calling a macro from assembler

Posted: Mon Oct 03, 2011 10:03 pm
by Dave S
Hi Jonny,

Thanks for that, I'll try it first thing in the morning. (Doesn't agree with the help file though!)

I've written a routine in assembler which receives data from a transmitter and I want to output the data via RS232 to check it has been received correctly using the flowcode macro.

I'll let you know how it goes.

Thanks again,

Dave.

Re: calling a macro from assembler

Posted: Mon Oct 03, 2011 10:27 pm
by JonnyW
Yeah - different C compilers have slightly different ASM syntax. It may have been that the help file documented a way to do it with one compiler which differed from another, or that the compiler documented used to behave like that but doesnt any more. We will hopefully try to make things like this clear in the future.

Its always difficult with ASM to pinpoint exact syntax as it varies so much from chip to chip and compiler to compiler. Thats why I was suprised that you were calling Flowcode macros from ASM, as it will be difficult to port, but thats the only reason really and there is no reason why you shouldnt be able to do this.

Good luck with the code,

Jonny

Re: calling a macro from assembler

Posted: Tue Oct 04, 2011 9:28 am
by Dave S
Hi Jonny,

Your syntax works fine, thanks again.

I'm not sure what you meant by "I am not familiar with PIC assembly but Im assuming you will have to push each argument you need first. You can view the C code and cut-paste the exact definition from there"

The line "call FCM_macro" can be inserted into the assembler and works as is.

Porting will not be a problem, I just want to output RS232 for debug purposes.

Dave.

Re: calling a macro from assembler

Posted: Tue Oct 04, 2011 1:10 pm
by JonnyW
I'm not sure what you meant by "I am not familiar with PIC assembly but Im assuming you will have to push each argument you need first. You can view the C code and cut-paste the exact definition from there"
Dont worry about it - I meant if you were calling a macro with multiple arguments, or using a different macro name, which youre not. Glad it all works OK.

Jonny