Question: Project 1-3, ASM, and Context Switch The table below illustrates a memory state where code pieces similar to part-3 of project 1 are loaded. For


Project 1-3, ASM, and Context Switch The table below illustrates a memory state where code pieces similar to part-3 of project 1 are loaded. For example, the code at Ox0000 implements switch_to(void ** loc_for_old_sp, void 'new_sp) function where the 1st argument is at ESP+4 and the 2nd argument is at ESP+8. /* switch to */ Ox0000 MOV EAX, [ESP + Ox0004) Ox0004 MOV (EAX), ESP Ox0008 MOV ESP, (ESP + Ox00081 Ox000C RET /* thread 2 / 0x2000 PUSH [OxD004) Ox2004 PUSH OxD000 Ox4018 0x2008 CALL Ox0000 0x200C HALT Ox5014 0x0010 HALT Ox6014 /* thread 1 */ /* thread 3 */ Ox3000 PUSH [OxD008) Ox7014 Ox3004 PUSH OxD004 Ox3008 CALL Ox0000 OXOFES MOV [OxD000], 0x5014 OXOFFC MOV [0x5014], 0x2000 Ox1000 MOV [OxD004), 0x6014 0x1004 MOV [0x6014], 0x3000 0x1008 MOV (OxD008], 0x7014 0x1000 PUSH [0x00001 Ox1010 PUSH OxD008 Ox300C HALT OxD000 OxD004 OxD008 0x1014 CALL Ox0000 Ox1018 HALT Here is some information to understand the assembly syntax. . You may assume all hexadecimal numbers are 4 bytes and all registers and memory accesses through the assembly instructions happen in a 4-byte granularity. Push/pop changes ESP by 4. ESP: stack pointer register. EIP: instruction pointer register. EAX, EBX: general purpose registers. . [X]: accesses the value in memory location X. MOV X, Y: copies Y into X. PUSH X: pushes X to the stack. POP X: pops the top element of the stack and stores it into X. CALL X: pushes the return address to the stack and jumps to X. RET: pops the return address from the stack and jumps to the return address. RET: pops the return address from the stack and jumps to the return address. HALT: stops execution. The system starts with ESP=0x4018 and EIP=OxOFF8 and executes the instructions until EIP reaches a HALT instruction. Follow the execution line by line and list all changes to the memory and the ESP register in the execution order in a space separated format "INS MEM_ADDR MEM_VAL ESP_VAL". If the EIP value jumps (e.g., due to CALL or RET instruction) then add a blank line. For example if the following code is executed, OxF000 MOV EAX, Ox1111 OxF008 MOV [Ox90001, EAX OXFOOC MOV [0x9000], 0x2222 0xF010 MOV EAX, [0x9000) OxF014 JME OXF088 OXF088 MOV ESP, 0x3333 OxF0BC HALT then your answer should be: // You do not need to include the comments // You should not include instructions that do not change the memory or ESP // Relevant instructions are: 1/ 0xF008 Mov changed the val of memory adr 0x9000 to 0x1111 and made no changes to ESP // OXFOOC MOV changed the val of memory adar 0x9000 to 0x2222 and made no changes to ESP 1/ 0xF014 JMP made EIP to jump // 0xF088 MOV changed ESP to 0x3333 // The answer should be: MOV Ox9000 Ox1111 NULL MOV 0x9000 Ox2222 NULL MOV NULL NULL Ox3333
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
