PDA

View Full Version : Changing Swordfish code to PBP



Ron Marcus
- 28th April 2008, 21:41
Hey guys,
I'm stumped with the Swordfish XTEA encryption code. Changing it over to PBPL 2.50 is difficult due to the fact it will only support 32 bit signed integers, not unsigned. Plus, in the structured environment, the variables are resized in each subroutine(ie. word or longword).
I can do separate variables in each sub, but the 32 bit math seems tricky. Would a long addition of one to$7FFFFFFF, make $80000000, or $00000000 with some kind of carry? Also, would the carry be lost, or is it recoverable somewhere?
Am I better off trying to break up the math operations into word variables?
The code is attached, any help would be greatly appreciated.
Thanks,
Ron
PS. I am buying Swordfish, so I don't feel bad about changing the code to fit a current project.

mackrackit
- 28th April 2008, 23:07
Would a long addition of one to$7FFFFFFF, make $80000000
Yes, $7FFFFFFF= 22147483647 $80000000 = 2147483648

That is about as much help as I can give. But it does look like you will need to divide by 10000 or so to make the numbers workable.

Ron Marcus
- 29th April 2008, 00:56
Yes, $7FFFFFFF= 2147483647 $80000000 = 2147483648

That is about as much help as I can give. But it does look like you will need to divide by 10000 or so to make the numbers workable.

My belief is that when bit #31 is set, it becomes a negative number in the eyes of PBPL.So it would be -2147483647

mackrackit
- 29th April 2008, 01:28
You might be right, I am still learning this new stuff and I have a way of making it more confusing than it needs to be, I guess.

If it is -2147483647 then the hex would be $FF8000001 ??? Now I see why you asked about the carry.
Or if -2147483647 +1 = -2147483646 = $FF80000002 and the absolute value would be $7FFFFFFE

I will be quiet now :o