In the name of God
......................................
Hi this is my code . i want to add 2 digits and then print them on screen :
what's wrong :

title myprog
.model small
.stack
.data
	num1 db 12
	num2 db 13
.code
 start :
	mov ax,@data
	mov ds,ax ; data segment
	
	mov ax,num1	;ax = num1
	add ax,num2   ;ax =ax+num2
	
	mov dx,offset ax	        ;moving offset of ax to dx for printing
	mov ah,09h		 	;calling 9th service
	int 21h				;print 
	mov ax , 4c00h          	;exit code
	int 21h
 end start

AS for the following .EXE assembly language source:

mov ax,@data
mov ds,ax ; data segment
mov ax,num1 ;ax = num1
add ax,num2 ;ax =ax+num2
mov dx,offset ax ;moving offset of ax to dx for printing
mov ah,09h ;calling 9th service
int 21h ;print
mov ax , 4c00h ;exit code
int 21h

I noticed
you are adding a byte sized variable to a 16-bit register
causing the location to be treated as a 16-bit WORD rather
than a byte, operands are always of complementary type,
even reg/mem.
AX is a register and does not have an offset,
you summed variables num1 and num2 in AX,
they must be converted to asci for printing.
The following calculation can be used for two-digit
decimal values:
12+13=25/10= 2 r 5
2+30h 5+30h
try this:

xor ah, ah ; initialize high-byte of AX
mov al, num2
add al, num1 ; sum variables in AL
mov bl, 10 ; place divisor in BL
div bl ; divide sum in AX by ten
       ; AH = rem AL = quotient
push ax
add al, 30h
mov dl, al ; DL=char to be printed
mov ah, 2 ; output char to stdout
int 21h ; print first digit
pop ax
add ah, 30h
mov dl, ah
mov ah, 2
int 21h ; print second digit
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.