Page 1 of 1

bit swap from c to PB

Posted: Wed Oct 12, 2016 3:04 pm
by supercdfr
i have this in c :

Code: Select all

printf("%u\n\n\n",(3967115105 << 28) | (3967115105 >> 4) )
And i have the result : 516380150 that is correct

When i try whit PB, i have this :

Code: Select all

Debug (3967115105 << 28) | (3967115105 >> 4)
i have 1064914352463107574 that is incorrect.

I try stru, strd strf, but the result is always false.

Re: bit swap from c to PB

Posted: Wed Oct 12, 2016 3:25 pm
by Shardik
To obtain a long integer you have to remove all unwanted digits with an AND $FFFFFFFF operation. The following code line therefore displays your wanted result:

Code: Select all

Debug ((3967115105 << 28) | (3967115105 >> 4)) & $FFFFFFFF ; Displays 516380150

Re: bit swap from c to PB

Posted: Wed Oct 12, 2016 3:48 pm
by supercdfr
1000 thanks :)

Re: bit swap from c to PB

Posted: Wed Oct 12, 2016 4:37 pm
by skywalk

Code: Select all

EnableExplicit
Define.q q = (3967115105 << 28) | (3967115105 >> 4)
Define.l l = q
Debug q
Debug l
l = ((3967115105 << 28) | (3967115105 >> 4))  ;OVERFLOW; & $FFFFFFFF
;[11:35:02] [COMPILER] Line 5: Overflow error: a 'long' value (.l) must be between -2147483648 And +4294967295.

Re: bit swap from c to PB

Posted: Wed Oct 12, 2016 5:14 pm
by wilbert

Code: Select all

l.l = 3967115105

EnableASM
ror l, 4
DisableASM

Debug l