Need help with PASM code
Siri
Posts: 220
Please help me with this code.I have a hard time to figure out what what is being done here and what are we trying to accomplish with this code.
I am lost at - test DataPinMask,INA wc.The use of Z & C flags are confusing.
A good explaination with details - apppreciated.
Thanks
Siri
Post Edited (Siri) : 9/18/2008 3:35:32 AM GMT
I am lost at - test DataPinMask,INA wc.The use of Z & C flags are confusing.
SHIFTIN mov DataBitMask,#1 'Create BitMask i.e - 00000001 shl DataBitMask,DataBits 'Set number of Bits i.e - 10000000 mov Data,#0 'Clear Data _ReadNextBit or outa,ClockPinMask 'Set Clock pin HIGH - Start Clock test DataPinMask,ina wc 'Load "C" with DataPin value muxc Data,DataBitMask 'Move "C" into Data via DataBitMask position andn outa,ClockPinMask 'Set Clock pin LOW - End Clock shr DataBitMask,#1 wz 'Move BitMask position right by 1 ' if_nz jmp #_ReadNextBit 'Jump to '_ReadNextBit' if there are more bits
A good explaination with details - apppreciated.
Thanks
Siri
Post Edited (Siri) : 9/18/2008 3:35:32 AM GMT
Comments
Can you edit you post and put the code in a code box, or attach the spin file? Your code has lost all its formatting.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Now if I understand correctly after the " MOV Data,#0 " instruction the Data bit is "00000000" - cleared to zero
The clock is started and begin reading each byte - then the 'Data input pin' state is read via " INA = 0 or 1 " then the "C" flag is set if parity is odd in other words if " INA=1/high"
Then " muxc Data,DataBitMask " sets the MSB of the Data byte to "1" i.e 10000000
Then sets the clock pin low - to start the next reading by making the clock high -
Then " shr DataBitMask,#1 " - moves the bit position Rt - 7th position and sets " Z " flag to "0 - zero" only if NO position to move- Byte is complete
Then " if_nz jmp #_ReadNextBit " if " z " flag is not set - go and get the next bit
This cycle of events continue untill all 8 bits are received and placed in the "Data byte"
I hope this is correct if not steer me in the right direction.
Thanks for the patience and time to teach a rookie beginner.
Siri