I'm working on a program which takes a person's name, loops through each character in the name, and combines each character using the XOR command. The program clears the AL register only, NOT the rest of the EAX register.The final XOR result is then stored in the AL register.
Code:
INCLUDE Irvine32.inc
.data
myName BYTE "Joe Smith",0
tempName BYTE SIZEOF myName DUP(0)
.code
main PROC
mov al,0
mov esi,0
mov ecx,SIZEOF myName
top:
xor al, myName[esi]
inc esi
loop top
call DumpRegs
exit
main ENDP
END main
When I run the program using the name "Joe Smith", this is the output I'm getting:
EAX=768D332B EBX=7EFDE000 ECX=00000000 EDX=00401005
ESI=0000000A EDI=00000000 EBP=0018FF94 ESP=0018FF8C
EIP-004033FA EFL=00000206 CF=0 SF=0 ZF=0 OF=0 AF=0 PF=1
And I should be getting this:
EAX=0000002B EBX=7EFDE000 ECX=00000000 EDX=00405000
ESI=00405009 EDI=00000000 EBP=0018FF94 ESP=0018FF8C
EIP=00401045 EFL=00000206 CF=0 SF=0 ZF=0 OF=0 AF=0 PF=1
I'm having a few other problems with this as well. First, I'm not sure how "Joe Smith" translates to 0000002B in hexadecimal. Also I'm just not sure if I'm storing the XOR result correctly in the AL register in order for it to come up with the right output. Any help is greatly appreciated, thanks.
OP asked I'm not sure how "Joe Smith" translates to 0000002B
in hexadecimal.
char ASCII binary hex
----- ----- --------- ---
J 74 0100 1010 4A
o 111 0110 1111 6F
e 101 0110 0101 65
(space) 32 0010 0000 20
S 83 0101 0011 53
m 109 0110 1101 6D
i 105 0110 1001 69
t 116 0111 0100 74
h 104 0110 1000 68
(zero) 0 0000 0000 00 (this was included but has no effect on XOR)
----- --------- ---
XOR = 43 0010 1011 2B
In each column of the binary bit values, an odd number of 1
bits will result in a 1
, an even number of 1
bits will result in a 0
.