算术中的汇编位存储限制 [英] Assembly bit memory limit in arithmetic

查看:61
本文介绍了算术中的汇编位存储限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加以下数字:40、90、50和155,我总共得到355.

I wanted to add the following numbers: 40, 90, 50 and 155 and I get a total of 355.

我想试验一下寄存器AL是否具有(2 ^ 8)-1的位限制,当我编译代码并执行代码时,我得到了1373331855的十进制数.这是怎么发生的?

I wanted to experiment and test out whether the register AL will have a bit limit of (2^8) - 1, and when I compiled the code and execute the code, I get decimal of 1376331855. How did that happen?

我还认为355大于255,因此应该显示溢出异常.

Also, I thought 355 is greater than 255, and as a result should display an overflow exception.

我了解如果使用MOVZX,我将能够将计算结果携带到AX的更高寄存器中.

I understand if I use MOVZX I will be able to carry the calculation into the higher register of AX.

此外,我对AL和AH之间的区别感到非常困惑. AL和AH的内存分配是否有所不同?

Also, I am very confused with the difference between AL and AH. Is there a different in memory allocation for AL and AH?

TITLE Adding              
INCLUDE Irvine32.inc

.code
main PROC

    mov al,0h             ; 
    add al,28h            ; 40

    add al,5Ah            ; 90 
    add al,32h            ;50
    add al,9Bh            ;155
                            ; total is 355
    call DumpRegs
    call writedec

exit
main ENDP
END main

推荐答案

据我了解,DumpRegs为您提供了EAX的输出.当我将您的答案转换为十六进制时,我得到5209284F,其中4F在AL中. 4F HEX是79个十进制,即335-256.AL寄存器仅包含8位,因此256是它可以容纳的最大无符号整数.

As I understand it, DumpRegs gives you the output of EAX. When I convert your answer to HEX, I get 5209284F, the 4F being in the AL. 4F HEX is 79 Decimal, which is 335 - 256. The AL register only holds 8 bits, so 256 is the maximum unsigned integer it can hold.

在开始之前清除EAX,结果可能更有意义.

Clear EAX before you begin and the results may make more sense.

这篇关于算术中的汇编位存储限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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