Inline assembly

General discussion on mikroBasic PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
arco
Posts: 312
Joined: 15 Apr 2008 13:54
Location: The Netherlands

Inline assembly

#1 Post by arco » 17 Jun 2013 13:56

Is there a list of inline assembly mnemonics that can be used with PIC24FJ? (It looks like MOV.D and PUSH.D aren't supported?)
Also I get "Argument out of range" in the following code?:

Code: Select all

'==============================================================================
Sub Function TestAssembly(Dim Addr As LongWord) As LongWord
'==============================================================================
Dim LTemp As Word

  LTemp = LoWord(Addr)
  Asm
    MOV TestAssembly_LTemp, W1       '<--- here out of range error...
  End Asm
  Result = 0
End Sub

Regards,

Peter.

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Inline assembly

#2 Post by dejan.odabasic » 18 Jun 2013 15:36

Hello,

All assembly mnemonics listed in MUC datasheet are supported, just make sure that you provide correct/valid arguments.
For example:

Code: Select all

    asm
      MOV.D W14, W0
    end;
Best regards.

arco
Posts: 312
Joined: 15 Apr 2008 13:54
Location: The Netherlands

Re: Inline assembly

#3 Post by arco » 18 Jun 2013 15:59

Thanks,

Why do I get an out of range error on the code I posted above?
Regards,

Peter.

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Inline assembly

#4 Post by dejan.odabasic » 19 Jun 2013 09:37

Hello,

Please take a look at 16-bit MCU and DSC Programmer’s Reference Manual document, which is available on Microchips website.
I'm guessing that you are trying to move f to destination.

Code: Select all

  Asm
    MOV #lo_addr(TestAssembly_LTemp), W1
  End Asm
Best regards.

arco
Posts: 312
Joined: 15 Apr 2008 13:54
Location: The Netherlands

Re: Inline assembly

#5 Post by arco » 19 Jun 2013 11:27

Thanks,
I already have the PIC24 Ref.Man.
So I cannot move a variable directly to a WREG? The MBPro manual has an example that does just that (topic: Asm statement -> accessing variables):

Code: Select all

MOV _myvar, w0                      ; move myvar to W0
Also, where are the descriptions for asm functions like #lo_addr en #hi_addr? (I suppose there are more)
They are not in the MBPro helpfile, nor in the reference manual or MPAsm30 helpfile...
Regards,

Peter.

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Inline assembly

#6 Post by dejan.odabasic » 25 Jun 2013 17:38

Hello,

I have tested this issue more thoroughly and problem is related only to local variables.
Global variables can be used as show in example.

Location of local variables depends on location of function frame in stack, that's why you can't use local variable as a argument for MOV instruction.

Currently, the only solution for local variables would be to compile the code without SSA optimizer so you can locate the local variable (offset from function fame address):

Code: Select all

  Asm
    MOV [W14+offset], W0
  End Asm
I have reported the lack of ASM function description, it will be corrected as soon as possible.

Best regards.

Post Reply

Return to “mikroBasic PRO for dsPIC30/33 and PIC24 General”