I made this procedure which prints a 16 bit number (the range should be 0-65535),
Below is the code, if I replace the line where the problem is(the big HERE in the code) with this cmp ax,32767
(take the number as a 16 bit presign ) everything works ok but when I have the 65535 as a max it messes up the output(just prints 1 char).
I had the idea that 16 bit registers in assembly can take numbers in the range of 0-(2^16-1),like the 8 bit registers can take in the range 0-(2^8-1)
emfanisi_arithmou proc near ;ax the digit
cmp ax,10
jl l101
cmp ax,100
jl l102
cmp ax,1000
jl l103
cmp ax,10000
jl l104
cmp ax,65535; <- HERE , HEY HERE DO YOU SEE ME?
jle l105
l101:
mov cx,1
jmp loop105
l102:
mov cx,2
jmp loop105
l103:
mov cx,3
jmp loop105
l104:
mov cx,4
jmp loop105
l105:
mov cx,5
loop105:
mov dx,0
mov bx,cx
dec bx
shl bx,1
mov bx,powerof10[bx]
div bx
push dx
mov dl,al
add dl,48
mov ah,2
int 21h
pop ax
loop loop105
ret
emfanisi_arithmou endp
powerof10 dw 1,10,100,1000,10000;in the data segment