0

I'm having a problem with adding two single digit numbers that the user gives (Since they are ASCII I do the add 48 thing, I know that doesn't work past 9, giving some guidance on this would really be appreciated). Anyways, heres the code.

variables:
Value1 db ?
Value2 db ?

inputting:
mov ah, 01
int 21h
mov Value1, al

mov ah, 01
int 21h
mov Value2, al

adding:
mov al, Value1
add al, Value2
add al, 48

outputting:
mov ah, 02
mov dl, al
int 21h

exit:
mov ah, 4Ch
mov AL, 00
int 21h

Excuse any newbish mistakes, this is my, er... Second day I think.

Forgot to say, I am using the A86 assembler.

Edited by hilo890: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by theUserMan
0

Excuse me, I forgot to add code brackets.

variables:
Value1 db ?
Value2 db ?

inputting:
mov ah, 01
int 21h
mov Value1, al

mov ah, 01
int 21h
mov Value2, al

adding:
mov al, Value1
add al, Value2
add al, 48

outputting:
mov ah, 02
mov dl, al
int 21h

exit:
mov ah, 4Ch
mov AL, 00
int 21h
0

i've never worked with the single registers

but maybe using like ebx, and eax would work for addition

i.e.

mov eax, prompt ;enter value
call print_string
call read_int

add ebx, eax ; move value entered into ebx as an accumulator

ofcourse you'd have to zero out ebx before hand and probably want to loop this and have an exit condition for when done entering then print out the sum with
call print_int

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.