在汇编程序x86中进行划分 [英] Dividing in Assembler x86

查看:65
本文介绍了在汇编程序x86中进行划分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的大学给我做运动:

1.在Jasmin中创建一个新文档

2.使用AL寄存器将9加上8.

3.减2.

4.除以7.

我的解决方法是:

mov al,9
add al,8
sub al,2

但是我如何除以7?我尝试了类似div al,7的方法,但这没用.

But how do I divide by 7? I tried something like div al,7 but that doesn't work.

推荐答案

div操作将AX,DX:AX或EDX:EAX寄存器中的值(除数)除以源操作数(除数)并将结果存储在AX(AH:AL),DX:AX或EDX:EAX寄存器中.

div operation divides (unsigned) the value in the AX, DX:AX, or EDX:EAX registers (dividend) by the source operand (divisor) and stores the result in the AX (AH:AL), DX:AX, or EDX:EAX registers.

因此,要将值除以al,您需要执行以下操作:

so, to divide value in al, you need to do:

mov ah, 0 # clean up ah, also you can do it before, like move ax, 9
mov bl, 7 # prepare divisor
div bl # al = ax / bl, ah = ax % bl

之后,al将包含商,而ah将包含余数

after that al will contain quotient and ah will contain remainder

这篇关于在汇编程序x86中进行划分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆