Getting 'ina' value in PASM
I am new to PASM and I'm trying to write a very simple driver for an ADC. Right now, I need to be able to see if a pin is high/low, and shift that value into a variable.
How is this done?
How is this done?
Comments
mov temp, INA test temp, my_pin wc ' sets carry if odd number of bits are set, 1 is odd [img]http://forums.parallax.com/images/smilies/wink.gif[/img] if_c jmp #lbl_pin_set ... ' When pin is not set it goes here lbl_pin_set it ends here when the pin is set temp long 0 my_pin long %0000_1000
You can also use the value of INA directly :
test my_pin, INA wc ' sets carry if odd number of bits are set, 1 is odd [img]http://forums.parallax.com/images/smilies/wink.gif[/img] if_c jmp #lbl_pin_set ... ' When pin is not set it goes here lbl_pin_set it ends here when the pin is set temp long 0 my_pin long %0000_1000
test INA, my_pin WC
rcl result, #1
or
rcr result, #1
rcl or rcr depends on the word order you have - for MSB first you need rcl, for LSB first you need rcr and if the result is smaller than 32 bit, you have to shift for 32-number_of_bits.
By the way ... as long as you don't write back (which test does not do) the order of the INA and my_pin is not relevant. The difference is, if you do it like I showed, you can use immediate value if your pin is one of the first nine pins.
test INA, #000100000 WC
This saves one long of memory (only for the case you get short with memory ;o)
Post Edited (MagIO2) : 4/17/2009 9:34:26 AM GMT
http://forums.parallax.com/showthread.php?p=800398
·
CON ''General Constants for Propeller Setup _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 PUB Main_Program cognew(@ASM_SpinTest,0) DAT ASM_SpinTest mov dira, OutputMask test InputPinMask{<-- pin-mask}, ina wc rcr DataIn, #1 mov outa, DataIn jmp #ASM_SpinTest InputPinMask long %00000000_00000000_00000000_00000001 OutputMask long %00000000_11111111_00000000_00000000 DataIn res 1
BTW)
If your data is comming in as inverted logic, you can rotate the "true" logic into "DataIn" this way...
andn InputPinMask{<-- pin-mask}, ina wc,nr rcr DataIn, #1
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 4/17/2009 3:03:28 PM GMT