如何使用div指令在x86汇编中找到余数? [英] How to use the div instruction to find remainder in x86 assembly?
本文介绍了如何使用div指令在x86汇编中找到余数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
mov eax, 0
mov ebx, 0
mov edx, 0
mov ax, 31
mul cx
mov bx, 12
div bx
add bp, ax
mov eax, 0
mov ebx, 0
mov bp, bp
mov al, 7
div al
有人能告诉我这段代码中的div指令有什么问题吗,所以当我调试我计算出的每一个bp数时,当我除以al时,它给我1作为余数,为什么会这样?
can anyone tell me whats wrong with the div al instruction in this block of code, so as I'm debugging every number of bp i calculated, when i divide by al it give me 1 as the remainder, why is this happen?
其余部分应存储回ah寄存器
the remainder should be store back to ah register
预先感谢
修改后的代码:
mov eax, 0
mov ebx, 0
mov edx, 0
mov ax, 31
mul cx
mov bx, 12
div bx
add bp, ax
mov eax, 0
mov ebx, 0
mov ax, bp
mov bl, 7
div bl
mov al, 0
推荐答案
修改后的代码:
mov eax, 0
mov ebx, 0
mov ax, 31
mul cx
mov bx, 12
div bx
add bp, ax
mov eax, 0
mov ebx, 0
mov edx, 0
mov ax, bp
mov bx, 7
div bx
mov esi, edx
mov eax, 0
这篇关于如何使用div指令在x86汇编中找到余数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文