Shop OBEX P1 Docs P2 Docs Learn Events
ASM with PropBasic — Parallax Forums

ASM with PropBasic

FriedVFriedV Posts: 77
edited 2011-09-21 11:51 in Propeller 1
Hi,
I can't get ASM Task to work with PropBasic.
In spin I have
' ASM Test File, runs in own Cog
' ASM_TEST, fgv 21.09.2011


CON
        _clkmode = xtal1 + pll16x                                              
        _xinfreq = 6_250_000

PUB Main
  cognew(@toggle,0)

DAT
        org 0
Toggle  mov dira, IOP
        mov time, cnt
        add time, #9
:loop   waitcnt time, delay
        xor outa, IOP
        jmp #:loop
'---------------------------
IOP     long  %1
delay   long  5_000_000
time    res   1
That code runs as expected, but in PropBasic this code won't work:
PROGRAM Main

Main:
  Cogstart Tog
    do
    loop
END

' ----- TASK Code ------------------------------------------------------
 TASK Tog
    ASM
            org 0
    Entry   mov dira, IOP                
            mov time, cnt
            add time, #9    
    :loop   waitcnt time, delay
            xor outa, IOP
            jmp #:loop
        '---------------------------
        IOP     long    %1
        delay   long    5_000_000
        time    res        1
    ENDASM
ENDTASK
Anybody sees why? I'm out of ideas....

Comments

  • BeanBean Posts: 8,129
    edited 2011-09-21 11:34
    You need to declare the TASK before PROGRAM. "Tog TASK AUTO", the AUTO just means to start the cog automatically at startup.

    Don't use ORG or define variables in ASM. Declare variables as PropBasic variables.

    You can't use RES in ASM...ENDASM. When spin sees the RES it doesn't set the value of any variables after it.
    DEVICE P8X32A,XTAL1,PLL16X
    FREQ 80_000_000
    
    Tog TASK AUTO
    
    PROGRAM Main
    
    Main:
      do
      loop
    END
    
    
    TASK Tog
      IOP   VAR LONG = %1
      delay VAR LONG = 5_000_000
      time  VAR LONG
    
      ASM
           mov dira, IOP
           mov time, cnt
           add time, #9
    :loop  waitcnt time, delay
           xor outa, IOP
           jmp #:loop
      ENDASM
    ENDTASK
    

    Bean
  • FriedVFriedV Posts: 77
    edited 2011-09-21 11:51
    Thanks Bean,
    that helped a lot!
    Fried
Sign In or Register to comment.