Hello and welcome to our community! Is this your first visit?
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
    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
    fullName BYTE "Joe",0		; Store name in string
    nameSize = ($ - fullName)			; Variable to store length of name
    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
    main ENDP
    END main

  2. #2
    Senior Coder
    Join Date
    Aug 2006
    Thanked 401 Times in 398 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.

  3. 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