Shop OBEX P1 Docs P2 Docs Learn Events
copy input pin to output pin in pasm — Parallax Forums

copy input pin to output pin in pasm

JkaneJkane Posts: 113
edited 2014-05-16 15:27 in Propeller 1
Hello,

still getting the hang of pasm,

in spin i think you can do this:

outa(6) := ina(5)

but in pasm it does not seem to be the same

so in pasm i have this: (copy input from pin 5 to output on pin 6)
/code

mov dira, dira_modeIO
:loop_15
test test_modeIO, ina wc
rcl tmp, #6
mov outa, tmp ' pin6_Pin15O


jmp #:loop_15


dira_modeIO long %00000000_00000000_11111111_1101111
test_modeIO long %0010_0000

code/

which in my thinking should work,

check pin 5,
set flag, 0 or 1
move to variable with shift
set outa with variable mask.


but it does not work, so i think it is with my mov,


regards

Jeff

Comments

  • CogSaverCogSaver Posts: 17
    edited 2014-05-16 14:25
    This can be done on 2 lines in PASM, assuming the pin directions and pinmasks are already set up.

    Unable to test on Propeller right now, but something close to
    test inmask,INA  wz
    muxz OUTA,outmask
    

    inmask and outmask will be longs with a 1 in the corresponding bit position,
    e.g.
    inmask  long  %00100000
    


    Edit; if pin gets inverted, use muxnz instead of muxz

    Hope this makes sense
    CogSaver
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-05-16 14:27
    A direct way to set that one bit is with the muxc command:

    test test_modeIO, ina wc
    muxc outa, Omask

    Omask long %10_0000

    A trouble with using rcl tmp,#6 is that it sets all low 6 bits to %11_1111 if carry is one.
  • kuronekokuroneko Posts: 3,623
    edited 2014-05-16 15:27
    Or use a counter which can read from pin A and write it inverted to pin B:
    movs ctra, #A
    movd ctra, #B
    movi ctra, #%0_01001_000
    
    This assumes that B is set as an output and the cog is kept alive otherwise.

    Also, in your original code you transfer the carry flag only up to bit 5:
    • rcl #1 -> bit 0
    • rcl #2 -> bits 1..0
    • rcl #6 -> bits 5..0
    You'd need at least an rcl tmp, #7 if you want bit 6 to be affected.
Sign In or Register to comment.