Check-sum using xor ^
L_Gaminde
Posts: 29
I am trying to make a list of check-sum values the code below works great but how do I get A through F into the variable a after it runs through 1 through 9
' {$STAMP BS2}
' {$PBASIC 2.5}
a VAR Word
b VAR Word
z VAR Word
start:
FOR a = 48 TO 57
FOR b = 48 TO 57
z = 59 ^a ^b ^78
DEBUG a,b," ",a,b,"N",HEX z,CR
PAUSE 500
NEXT
FOR b = 65 TO 70
z = 59 ^48 ^b ^78
DEBUG a,b," ",a,b,"N",HEX z, CR
PAUSE 500
NEXT
NEXT
END
' {$STAMP BS2}
' {$PBASIC 2.5}
a VAR Word
b VAR Word
z VAR Word
start:
FOR a = 48 TO 57
FOR b = 48 TO 57
z = 59 ^a ^b ^78
DEBUG a,b," ",a,b,"N",HEX z,CR
PAUSE 500
NEXT
FOR b = 65 TO 70
z = 59 ^48 ^b ^78
DEBUG a,b," ",a,b,"N",HEX z, CR
PAUSE 500
NEXT
NEXT
END

Comments
' {$STAMP BS2}
' {$PBASIC 2.5}
a VAR Word
b VAR Word
z VAR Word
start:
FOR a = 48 TO 57
FOR b = 48 TO 57
z = 59 ^a ^b ^78
DEBUG a,b," ",a,b,"N",HEX z,CR
PAUSE 500
NEXT
FOR b = 65 TO 70
z = 59 ^48 ^b ^78
DEBUG a,b," ",a,b,"N",HEX z, CR
PAUSE 500
NEXT
NEXT
FOR a = 65 TO 70
FOR b = 48 TO 57
z = 59 ^a ^b ^78
DEBUG a,b," ",a,b,"N",HEX z,CR
PAUSE 500
NEXT
FOR b = 65 TO 70
z = 59 ^48 ^b ^78
DEBUG a,b," ",a,b,"N",HEX z, CR
PAUSE 500
NEXT
NEXT
END
[SIZE=1][FONT=courier new]a VAR BYTE x VAR BYTE b VAR BYTE y VAR BYTE z VAR WORD FOR a=48 TO 63 IF a>57 THEN x=a+7 FOR b=48 TO 63 IF b>57 THEN y=b+7 z = 59 ^ x ^ y ^ 78 DEBUG x,y," ",x,y,"N",HEX z,CR PAUSE 500 NEXT NEXT [/FONT][/SIZE]The bitwise xor operation is commutative, so I think you can replace the 59^78 with one ^117.
thanks Tracy I think this is the first thing you posted for me that I did not have to look at for a few hours to understand. after 10 years I'm still trying to figure out your Julian stuff.
SO is there a way to print out the Debug list?
' {$STAMP BS2}
' {$PBASIC 2.5}
a VAR Byte
x VAR Byte
b VAR Byte
y VAR Byte
z VAR Word
FOR a = 48 TO 63
IF a > 57 THEN a = a + 7
FOR b = 48 TO 63
IF b > 57 THEN b = b + 7
z = 59 ^ a ^ b ^ 78
DEBUG a,b," ",a,b,"N",HEX2 z,CR
PAUSE 100
NEXT
NEXT
The value of z is the only one being printed out as 00 to FF.
Print out the debug list--Capture the list using a terminal program, Putty, CoolTerm, Hyperterminal etc. Then print the text file.
(Ah, Julian time is quite a numbers game!)
yours starts at AA and goes to FF but skips the lower set 00 to 9F because of the X-Y in the debug statement so I need to implement you thinking into something a little different.