I am working on a problem for my introductory computer organization course at UCI and we use x86 assembly language in the course (using Visual Studio and the MS syntax). While the problem is for a homework assignment, we are graded on attempts and not the correctness of our answers.
My question is w.r.t indirect memory addressing. The entire question is stated below:
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 |
I understand that byte ptr [EBX]
will load the value 0xFF
and that question (A) essentially boils down to ADD 0xFF, 0x01
using a memory address of one byte. However, what I do not understand is how to deal with the overflow caused by '0x100' which would require a minimum of 9 bits to represent.
The two possible solutions I can determine for question (A) ADD byte ptr [EBX], 1
are as follows:
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
QUESTION: what effect does the overflow of representing a 9 bit result of an ADD operation in a single byte of memory have on any subsequent memory regions, if any
Any insight that anyone could shed on this topic would be greatly appreciated as I was not able to find any x86 specific information that dealt with the overflow of storing a 9 bit number in a single byte of memory.