. What value will EAX contain after the following instructions execute? .data dVal DWORD 12345678h .code mov ax,3 mov WORD PTR dVal+2,ax mov eax,dVal
Question
. What value will EAX contain after the following instructions execute? .data dVal DWORD 12345678h .code mov ax,3 mov WORD PTR dVal+2,ax mov eax,dVal
Solution 1
The given assembly code is doing the following:
-
It first moves the value 3 into the AX register. The AX register is the lower 16 bits of the EAX register.
-
Then it moves the value in AX (which is 3) into the third and fourth bytes of the variable dVal. The original value of dVal is 12345678h, which in binary is 0001 0010 0011 0100 0101 0110 0111 1000. After the move operation, the third and fourth bytes (0100 0101) are replaced by the binary representation of 3 (0000 0011), so dVal becomes 0001 0010 0000 0011 0110 0111 1000.
-
Finally, it moves the value of dVal into the EAX register.
So, after these instructions execute, EAX will contain the value 12000378h.
Solution 2
The instructions are written in Assembly language. Here's a step-by-step explanation of what happens:
-
mov ax,3: This instruction moves the value 3 into the AX register. The AX register is the lower 16 bits of the EAX register. -
mov WORD PTR dVal+2,ax: This instruction moves the value in the AX register (which is 3) into the memory locationdVal+2. SincedValis a DWORD (32 bits or 4 bytes),dVal+2refers to the third and fourth bytes ofdVal. The original value ofdValis12345678h(in hexadecimal), which in binary is0001 0010 0011 0100 0101 0110 0111 1000. After this instruction, the third and fourth bytes (counting from the right) are replaced with the binary representation of 3 (0000 0011), sodValbecomes0001 0010 0000 0011 0111 1000in binary, or1200378hin hexadecimal. -
mov eax,dVal: This instruction moves the value indValinto the EAX register. So, after this instruction, EAX will contain1200378h(in hexadecimal).
Similar Questions
What will be the value in EAX after the following lines execute?mov eax, 1002FFFFhneg ax
What will be the value in EAX after the following lines execute?mov eax, 30020000hdec ax
2. What will be the value in EDX after each of the lines marked (a) and (b) execute? .data one WORD 8002h two WORD 4321h .code mov edx,21348041h movsx edx,one ; (a) movsx edx,two ; (b)
What will be the value of EAX and the Sign flag after the following lines execute?mov eax, 5sub eax, 6
The content of AC in the basic computer is hexadecimal A937 and the initialvalue of E is 1. Determine the contents of AC, E, PC, AR, and IR in hexadecimalafter the execution of the CLA instruction. Repeat 11 more times, starting fromeach one of the register-reference instructions. The initial value of PC is hexa-decimal 021
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.