gpt4 book ai didi

汇编:16 位除法

转载 作者:行者123 更新时间:2023-12-04 23:59:29 28 4
gpt4 key购买 nike

我还是汇编的新手,我还不知道汇编中的许多命令代码。我想在 16 位寄存器中进行除法。我想打印它的内容。我知道我需要将寄存器的内容转换为 ASCII 进行打印,但同样,我的问题是除法。请帮我。

比如cx的内容是2012(整数)。我该怎么办?

 mov ax, cx
mov bx, 1000
idiv bx

上面的代码是错误的,对吧?

最佳答案

退房 this reference (搜索 idiv)

The idiv instruction divides the contents of the 64 bit integer EDX:EAX (constructed by viewing EDX as the most significant four bytes and EAX as the least significant four bytes) by the specified operand value. The quotient result of the division is stored into EAX, while the remainder is placed in EDX. Syntax idiv idiv

Examples

idiv ebx — divide the contents of EDX:EAX by the contents of EBX. Place the quotient in EAX and the remainder in EDX. idiv DWORD PTR [var] — divide the contents of EDX:EAS by the 32-bit value stored at memory location var. Place the quotient in EAX and the remainder in EDX.



当然,由于您使用的是 16 位,请将所有指定的位值减半并将每个寄存器的 E 去掉,这是完全相同的

关于汇编:16 位除法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12389576/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com