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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.