First of all, this is homework.
I am trying to read a 5 digit number in the bx register. It is assumed that the number does not exceed 65535 (16 bits). Below I am trying to do this.
However, when I try to print the number, I only print the last digit that was entered. This leads me to the assumption that when I add another number to bx, it overwrites the previous number, but I do not see the problem. Any help would be appreciated, I'm pretty sure this is something small, I don't notice: - /
mov cx,0x05 ; loop 5 times mov bx,0 ; clear the register we are going to store our result in mov dx,10 ; set our divisor to 10 read: mov ah,0x01 ; read a character function int 0x21 ; store the character in al sub al,0x30 ; convert ascii number to its decimal equivalent and ax,0x000F ; set higher bits of ax to 0, so we are left with the decimal push ax ; store the number on the stack, this is the single digit that was typed ; at this point we have read the char, converted it to decimal, and pushed it onto the stack mov ax,bx ; move our total into ax mul dx ; multiply our total by 10, to shift it right 1 pop bx ; pop our single digit into bx add bx,ax ; add our total to bx loop read ; read another char
assembly nasm multiplication
Adam
source share