copy input pin to output pin in pasm
Jkane
Posts: 113
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
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
Unable to test on Propeller right now, but something close to
inmask and outmask will be longs with a 1 in the corresponding bit position,
e.g.
Edit; if pin gets inverted, use muxnz instead of muxz
Hope this makes sense
CogSaver
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.
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.