I have to take 16 bit as an input as 1234 and tried to display it. But it gives output as 4660. I tried to store digit by digit because when I take input, it will get stored in al
as in ASCII form. After that I tried to shift the whole bit in al
to left using shift left(SHL
) operation which will give me 10 in al
if I have inserted 1. After that I inserted second digit and performing shift and rotate operation, I tried to make it in 02 form if the second digit stored is 2. Further, I performed OR
operation on 10 and 02 which are stored in register. I repeated the same process for storing lower 8-bit number. But the output is different.
.model small
.stack 100h
.data
.code
main proc
mov ax,@data
mov ds,ax
;taking 16 bit number input
mov ah,01h
int 21h
mov bh,al
mov cl,4
shl bh,cl
mov ah,01h
int 21h
mov cl,4
shl al,cl
mov cl,4
ror al,cl
or bh,al
mov ah,01h
int 21h
mov bl,al
mov cl,4
shl bl,cl
mov ah,01h
int 21h
mov cl,4
shl al,cl
mov cl,4
ror al,cl
or bl,al
;taking 16 bit number input
;displaying number in dos
mov ax,bx
mov bx,10
xor cx,cx
.a:
xor dx,dx
div bx
push dx
inc cx
test ax,ax
jnz .a
.b:
pop dx
add dl,"0"
mov ah,02h
int 21h
loop .b
exit:
mov ah,4ch
int 21h
main endp
end main