0
votes

QUESTION: Fill the gaps with the values that are saved in the respective register after executing the respective line. Enter all values in hexadecimal and in 32 bits.

MY THINKING: I'm new at Assembly. I know that values like EAX, EBX, ECX, EDX, ESI, EDI, ESP, or EBP are for any 32-bit register. Or the values like AX, BX, CX, or DX are for any 16-bit register. I've read that xor eax, eax — set the contents of EAX to zero. That means that the first gap is 0x00000000, right? Second gap copies the 0x12345678 into eax. That means eax = 0x12345678. 3rd gap should be 0x00000000 too, because 0 copies the value into ebx? And for other gaps I could not find anything.

xor eax, eax           ; eax = 0x00000000 (Gap 1)
mov eax, 0x12345678    ; eax = 0x12345678 (Gap 2)
mov ebx, 0
mov bx, ax             ; ebx = 0x00005678 (Gap 3)
mov bl, ah             ; ebx = 0x00005656 (Gap 4)
mov eax, 0xFFFFFFFF   
sar eax, 8             ; eax = 0xFFFFFFFF (Gap 5)
shr eax, 8             ; eax = 0x00000000 (Gap 6)
sar eax, 8             ; eax = 0x00000000 (Gap 7)
ror eax, 8             ; eax = 0x00000000 (Gap 8)
1
Yes, the first two results are correct. As for the rest remember that ax is not just a 16 bit register, it's specifically the low 16 bits of eax. That should cover the next two blanks. For the final four you should know what the instructions do, consult an instruction set reference. You can also run the code in a debugger to verify your values.Jester
please fill in your answers firstold_timer
Okay, I ll edit it in my question.Hakunamatata
#4 is wrong, bl is the lowest byte.Jester
Okay, now I think #4 ist correct.Hakunamatata

1 Answers

0
votes
mov eax, 0x12345678    ; eax = 0x12345678 (Gap 2)
mov ebx, 0
mov bx, ax             ; ebx = 0x00005678 (Gap 3)
mov bl, ah             ; ebx = 0x00005656 (Gap 4)
mov eax, 0xFFFFFFFF   
sar eax, 8             ; eax = 0xFFFFFFFF (Gap 5)
shr eax, 8             ; eax = 0x00FFFFFF (Gap 6)
sar eax, 8             ; eax = 0x0000FFFF(Gap 7)
ror eax, 8             ; eax = 0xFF0000FF(Gap 8)

I think I got it.