Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2013
    Posts
    4
    Thanks
    1
    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!

    Code:
    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

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,235
    Thanks
    10
    Thanked 270 Times in 269 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:

    jeaninem71 (09-06-2013)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •