Menu

How to pass variables or the stack into inline assembly in FF?

Amt
2021-09-03
2021-09-03
  • Amt

    Amt - 2021-09-03

    This is on FF 5.0 on a PIC18F4520 chip. I tried creating a variable x and then wrote inline assembly to use it but it doesn't work. Could you advice on the right way to pass variables or the parameter stack to inline assembly?

    see test2
    2fd8 51a6 movf a6 w b
    2fda 0bfa andlw fa
    2fdc 6fa6 movwf a6 b
    2fde 0012 return

     
  • Mikael Nordman

    Mikael Nordman - 2021-09-03

    This will xor the top of the stack with a variable.

    ram variable myVar  ok<$,ram>
    : myWord  
     [ myVar 8 rshift movlb, ] 
     [ (sp-) w, a, movf, ] 
     [ myVar 1+ f, b, xorwf, ] 
     [ (sp-) w, a, movf, ] 
     [ myVar f, b, xorwf, ] 
    ;  ok<$,ram>
    myVar @  ok<$,ram>0 
    5555 myVar !  ok<$,ram>0 
    . 0  ok<$,ram>
    myVar @ . 5555  ok<$,ram>
    5555 myWord  ok<$,ram>
    myVar @ . 0  ok<$,ram>
    5555 myWord  ok<$,ram>
    myVar @ . 5555  ok<$,ram>
    myVar  ok<$,ram>f108 
    .. .. ?
      ok<$,ram>
    see myWord 
    3676 01f1 movlb f1 
    3678 50ed movf (sp-) w a
    367a 1b09 xorwf 09 f b
    367c 50ed movf (sp-) w a
    367e 1b08 xorwf 08 f b
    3680 0012 return
    
     
    👍
    1

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.