Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
09-04-2013, 05:28 AM #1
- Join Date
- Aug 2013
- Thanked 0 Times in 0 Posts
x86 assembly program not adding up correctly
Newbie here so be kind please. I need AL to sum the ASCII characters in a name. For example, Joe should be 13E, but it is coming up 11E. If I put a space before and after Joe in the string, it sums up correctly. Can anyone see what I am doing wrong? Thanks for your help!
INCLUDE Irvine32.inc .data fullName BYTE "Joe",0 ; Store name in string nameSize = ($ - fullName) ; Variable to store length of name .code main PROC mov ECX,nameSize ; Set counter for loop mov ESI,OFFSET fullName ; Set pointer at name variable mov EAX,0 ; Clear the EAX register mov EBX,0 ; Clear the EBX register checkSum: ; Loop mov AL,[ESI + ECX - 1] ; Move to AL (8 bit register), point to characters in string add EBX,EAX ; Add EAX and EBX registers together loop checkSum ; Loop mov EAX,EBX ; Move EBX to EAX mov EBX,0 ; Clear EBX register call DumpRegs ; Display results exit main ENDP END main
09-04-2013, 03:13 PM #2
- Join Date
- Aug 2006
- Thanked 342 Times in 340 Posts
"Joe" looks to me like it sums to 11E. Are you sure you've looked it up with the "J" uppercase?
Nice to see someone writing assembly language.
Users who have thanked tracknut for this post: