Question: The control and memory unit of your CPU is in charge of processing the instructions that relate to flow control ( call , ret, jmp

The control and memory unit of your CPU is in charge of processing the instructions that relate to flow control (call, ret, jmp, j*, cmp, test) and memory movements (mov*, push, pop). In src/cmu.c, you will implement the following functions implement them in that order.
Call/ret (note that the argument of the call instruction is relative to the current RIP, and indicates an 8-byte signed displacement, i.e., if *A is -10 as a signed 8-byte integer, then this call will remove 10 from the RIP).
/*
* Calls the function at address *A. In practice, this:
*- Pushes the current RIP (cpu_state->rip) onto the stack, i.e., decrease RSP
*(cpu_state->regs[REG_RSP]) by 8, then store the RIP at the address
* indicated by RSP.
*-_Add_ the 8-byte signed integer *A to the current RIP.
*
* CORRESPONDING INSTRUCTION: call
*/
void op_call (cpu_state_t* cpu_state, uint8_t* a)
/*
* Returns from a function. In practice, this:
*- Sets the RIP to the 8-byte integer at the top of the stack,
*- Increase RSP by 8.
*
* CORRESPONDING INSTRUCTION: ret
*/
void op_ret (cpu_state_t* cpu_state)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!