Shop OBEX P1 Docs P2 Docs Learn Events
PASM SubRoutines — Parallax Forums

PASM SubRoutines

bsilvereaglebsilvereagle Posts: 6
edited 2012-11-23 19:38 in Propeller 1
I am trying to create a PASM subroutine for the following block of code:
IF_NZ AND input, #10
IF_NZ SHR input, #1
IF_NZ ADD data_byte, input
IF_NZ SHL data_byte, #1

When the code is implemented like below, when using pPropllerSim the value of "data_byte" changes to 3 (0b0010):
SPI_READ
  MOV input, #11
  'MOV input, ina
  TEST input, #01, wz  'Sets wz to 1 if clock is 0
  IF_NZ AND input, #10
  IF_NZ SHR input, #1
  IF_NZ ADD data_byte, input
  IF_NZ SHL data_byte, #1

However, when the below code is ran, "data_byte" does not change
SPI_READ
    MOV input, #11
    'MOV input, ina
    TEST input, #01, wz  'Sets wz to 1 if clock is 0
    IF_NZ call #READ_MOSI
    jmp #FINISH
READ_MOSI
    AND input, #10
    SHR input, #1
    ADD data_byte, input
    SHL data_byte, #1
READ_MOSI_ret ret    
FINISH
    jmp #FINISH


input long 0
data_byte long 0

Any help would be appreciated.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-23 19:11
    I'm not sure if this is the reason, but there should not be a comma between the #01 and the wz of the TEST instructions. I don't know what the assembler generates with the comma there, but it's not supposed to be there.
  • bsilvereaglebsilvereagle Posts: 6
    edited 2012-11-23 19:15
    The data_byte value still doesn't change, thanks for the input though.
  • kuronekokuroneko Posts: 3,623
    edited 2012-11-23 19:24
    I'm running this example on real hardware and I get the expected result (%10). Can you verify that this is what you wrote as it seems you're using an editor mode which eats the binary indicator?
    DAT             org     0
    
    SPI_READ        MOV     input, #%11
    '               [COLOR="#D3D3D3"]MOV     input, ina[/COLOR]
                    TEST    input, #%01 wz 'Sets wz to 1 if clock is 0
            IF_NZ   call    #READ_MOSI
                    jmp     #FINISH
    
    READ_MOSI       AND     input, #%10
                    SHR     input, #1
                    ADD     data_byte, input
                    SHL     data_byte, #1
    READ_MOSI_ret   ret  
    
    FINISH          mov     dira, mask
                    mov     outa, data_byte
                    rev     outa, #{32-}8
                    waitpeq $, #0
    
    
    input           long    0
    data_byte       long    0
    mask            long    $00FF0000
    
  • bsilvereaglebsilvereagle Posts: 6
    edited 2012-11-23 19:38
    Well I guess there is a bug in pPropellerSim. Your code still results in data_byte being 0 when run on the simulator.

    I suppose I should test on real hardware :P

    Thanks kuroneko & Mike.
Sign In or Register to comment.