Thanks alot ! it works :DDDDD Thank you! :DDDDDD
heres the final code in TASM :D
.model small
.stack 100h
.data
a db 0
t1 db,10,13, "Enter a number: $"
t2 db,10,13, "The sum is: $"
.code
main proc
mov ax,@data
mov ds,ax
mov ah, 9
lea dx, t1
int 21h
mov ah, 1
int 21h ; to get a single number input from the user
sub al, 30h ; to make the input number to decimal
mov a, al ; move the content of al to a variable
mov ah, 9
lea dx, t1
int 21h
mov ah, 1
int 21h
sub al, 30h
add al, a ; add the contents of al and a
push ax
mov ah, 9
lea dx, t2
int 21h
pop ax
xor ah,ah ;ah=0
call put_num
mov ah,4ch
int 21h
main endp
put_num proc ;function put_num: prints value stored in the ax register
;(a 16 bit integer) to stdout
push ax ;save registers
push bx
push cx
push dx
xor cx,cx ;cx=0
mov bx,10d ;bx=10(decimal)
PNloop1:xor dx,dx ;dx=0
div bx ;dx=ax/bx
push dx ;push the result in stack
inc cx ;cx++(cx acts like a counter to notify how many digits in the number)
cmp ax,0 ;but if the ax was zero,
jnz PNloop1 ;then jump to PNloop1
mov ah,2 ;otherwise...(Dos function to print a character)
PNloop2:pop dx ;get the value just pushed in to the stack in dx,
add dl,48 ;convert it in to ascii
int 21h ;and print it
dec cx ;decrease counter
jnz PNloop2 ;if cx not zero (still digits left) then loop again.
;otherwise ..
pop dx ;restore registers and return
pop cx
pop bx
pop ax
ret
put_num endp
end