I have the number 10 divided by 10, I wish to display the values, that are in ax, and dx, but TASM will not allow me to move ax, nor dx, into dl to display them side by side
.model small
.stack 100h
.data
Integer dw 5h
Numbre dw 5h
.code
Start:
mov ax,@data
mov ds,ax
mov ax,Integer
mov bx,Numbre
add ax,bx
mov cx,10h
mov dx,0h
jmp compare
compare : cmp ax,09
ja divide
jbe display_result
divide : div cx
add ax,"0"
add dx,"0"
jmp display_result_large
display_result : add ax,"0"
mov dl,ax
mov ah,2h
int 21h
jmp endall
display_result_large : mov dl,ax
mov ah,2h
int 21h
mov dl,dx
mov ah,2h
int 21h
jmp endall
endall : mov ah,4ch
int 21h
end Start
dl
is an 8-bit register -ax
anddx
are 16-bit registers. You can access the low and high byte ofax
asal
andah
, and ofdx
asdl
anddh
. So instead ofmov dl, ax
you should usemov dl,al
.The instruction
mov dl,dx
would be replaced bymov dl,dl
, but that would be a pointless operation. However, since you changeddl
's value when you didmov dl,al
you'll have to save and restore it somehow. The easiest way would be to use the stack: