Adding signed bytes in PASM
CogSaver
Posts: 17
I may be over complicating this, but all I need to do is add some signed bytes that are read from hub with rdbyte.
I understand the "adds D,S" command, but for that to work I need to get my signed byte values extended to longs.
I fail to find any "sign extend" command (like the ~ in SPIN) to make a signed long from my signed bytes, and in case this command
does not exist, will it be as simple as copying the most significant bit in the bytevalue into the upper 24 bits if the long ?
(test bit 7 then OR with the upper 24 bits set if negative)
Any help appreciated.
CogSaver
I understand the "adds D,S" command, but for that to work I need to get my signed byte values extended to longs.
I fail to find any "sign extend" command (like the ~ in SPIN) to make a signed long from my signed bytes, and in case this command
does not exist, will it be as simple as copying the most significant bit in the bytevalue into the upper 24 bits if the long ?
(test bit 7 then OR with the upper 24 bits set if negative)
Any help appreciated.
CogSaver
Comments
After a quick detour, thinking I had to do this with the help of the C-flag (apparantly any left shift or rotate with the WC effect specified, the C flag is set equal to Values original bit 31) I ended up with the following :
CogSaver
The setting of the C flag for shifts isn't what people expect. I think I read that it has been fixed in the Prop II.