ASM shift register brain lock
bte2
Posts: 154
Hi all, I have a string of 3 CD4014 PISOs which are reading 24 different switches for a fault monitoring system.
I have it running perfectly in Spin, but I have been trying to learn ASM lately, and I am stuck on a kinda basic problem.
I don't want anybody to provide finished code or anything, and I searched and could only find Spin examples. I also looked through the Object Exchange.
I have synchronous serial data arriving on Port P19 (pin 22 QFP). I want to put this pin state into the LSB of a long variable, shift it left, clock the 4014s, and repeat this 23 more times, and end up with a long with the upper 8 bits clear, and the lower 24 bits reflecting the states of the 24 inputs on the 4014s.
I have everything figured out except the part about actually putting P19 into bit 0 of my variable. My clock and latch outputs appear to be working fine, so I know I am not too far off.
I clear the variable before calling the shift loop, so if the serial data is 0 I can just shift the already existing 0 into the LSB.
This would imply a simple 'if-then' ie; IF (PIN=1) THEN VAR.BIT0 = 1, but I am having trouble thinking through exactly what I need to do in Propeller Assembly.
The project runs fine in Spin, this is only for my own edification. Thanks in advance.
I have it running perfectly in Spin, but I have been trying to learn ASM lately, and I am stuck on a kinda basic problem.
I don't want anybody to provide finished code or anything, and I searched and could only find Spin examples. I also looked through the Object Exchange.
I have synchronous serial data arriving on Port P19 (pin 22 QFP). I want to put this pin state into the LSB of a long variable, shift it left, clock the 4014s, and repeat this 23 more times, and end up with a long with the upper 8 bits clear, and the lower 24 bits reflecting the states of the 24 inputs on the 4014s.
I have everything figured out except the part about actually putting P19 into bit 0 of my variable. My clock and latch outputs appear to be working fine, so I know I am not too far off.
I clear the variable before calling the shift loop, so if the serial data is 0 I can just shift the already existing 0 into the LSB.
This would imply a simple 'if-then' ie; IF (PIN=1) THEN VAR.BIT0 = 1, but I am having trouble thinking through exactly what I need to do in Propeller Assembly.
The project runs fine in Spin, this is only for my own edification. Thanks in advance.
Comments
The more PASMish way is to do a test on ina, using a mask in the dst field, setting the z flag. Then, use that condition to or a 1 into your result or not.
-Phil
If you could help me get past this last mental block, I sure would be much appreciative.
I am having a little trouble figuring out how to TEST ina, using a 9-bit literal. This seems to be a recurring stumbling block for me, merging the 32-bit memory and IO aspects of the Propeller with the 9-bit operand limitations of PASM.
It is entirely possible that I am just overthinking this and my brain is getting in the way.
I promise that I am reading the manuals, and not looking for any easy way out.
Thanks big, -bry
ETA- I think that it has to do with assigning the bit mask to a memory location (that can be referenced with 9 bits), and using that as the mask, but like I said, I am having a serious brain lock for some reason.
'Sorry for being so terse. When I said to put the mask in the dst field, I should have explained why. Thankfully Mike was there, not only to cover for me, but to provide an even shorter solution!
-Phil
None taken- thank you for responding, I really do appreciate it!