Answer the question
In order to leave comments, you need to log in
How to divide numbers in incomplete registers?
Good morning!
I'm trying to divide two numbers using idiv. The problem is that it works with full registers (ax, bx), while my values are stored in half registers with the db type. If I try to divide like this, then the program freezes, and if I try to convert, huge values are obtained. How to be?
; поделим a / b
; так зависает
mov al, dl
mov bl, dh
cwd
idiv bl
; так тоже зависает, а напрямую mov ax, dl нельзя
mov ah, dl
mov ah, 00
mov bh, dh
mov bh, 00
cwd
idiv bl
Answer the question
In order to leave comments, you need to log in
In addition to manually resetting the upper halves of 16-bit registers, there are (starting with i386) movzx and movsx instructions that move data between registers of different sizes, expanding them with zero or a sign.
Those.
mov al, dl
mov ah, 0
movzx ax, dl
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question