处理 9 位结果溢出到应该存储在 x86 中的字节 ptr 中的 ADD 操作

Dealing with the overflow of a 9bit result to an ADD op that is supposed to store in a byte ptr in x86

我正在为我在 UCI 的介绍性计算机组织课程解决一个问题,我们在课程中使用 x86 汇编语言(使用 Visual Studio 和 MS 语法)。虽然问题是家庭作业,但我们会根据尝试而不是答案的正确性来评分。

我的问题是w.r.t间接内存寻址。整个问题如下:

Suppose EBX = 1000 (in decimal) and the byte values stored in the memory addresses 1000 through 1003 are 255, 255, 255, and 255 (in decimal). What effect do the following instructions have (independently) on this area of memory? Assume for multi-byte data, least significant byte is stored in smallest address.

a. ADD byte ptr [EBX], 1

   ADDRESS | Before | After
     1000  |  255   |          ; The After column is where we place our answers.
     1001  |  255   |          ; All of these values are unsigned
     1002  |  255   |
     1003  |  255   |

b. ADD word ptr [EBX], 1

   ADDRESS | Before | After
     1000  |  255   |   
     1001  |  255   |    
     1002  |  255   |
     1003  |  255   |

c. ADD dword ptr [EBX], 1

   ADDRESS | Before | After
     1000  |  255   |   
     1001  |  255   |    
     1002  |  255   |
     1003  |  255   |

我知道 byte ptr [EBX] 将加载值 0xFF 并且问题 (A) 本质上归结为 ADD 0xFF, 0x01 使用一个字节的内存地址。但是,我不明白的是如何处理'0x100'引起的溢出,这至少需要9位来表示。

对于问题(A)ADD byte ptr [EBX], 1我可以确定的两种可能的解决方案如下:

   ADDRESS | Before | After
     1000  |  255   |  000    ; Overflow does not carry out to address 1001 and the most significant bit is lost
     1001  |  255   |  255
     1002  |  255   |  255
     1003  |  255   |  255

   ADDRESS | Before | After
     1000  |  255   |  000    ; Overflow overwrites the value in the next memory address
     1001  |  255   |  001    ; [base 10]
     1002  |  255   |  255
     1003  |  255   |  255

问题:在单个内存字节中表示 ADD 操作的 9 位结果的溢出对任何后续内存区域有什么影响,如果有的话

任何人都可以就此主题提出的任何见解将不胜感激,因为我找不到任何 x86 特定信息来处理在单个内存字节中存储 9 位数字的溢出问题。

在每种情况下,从内存中检索的值(字节、字或双字)+1 将产生零并设置溢出标志,因为实际结果无法存储在可用的 space 中.该零将返回到内存中,并且 CPU 将在其状态寄存器中设置溢出位。设置溢出位的事实将允许作为结果执行操作 - 它不会影响存储到内存中的内容。

想想几百到几十个单位(如果仍然教授的话)。如果你有 9 加 1,你会得到 0 和 "overflow"。 99+1 得到 00 +溢出; 999+1 得到 000 +溢出