Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

6 Why did I not receive the material?

Answered: 1 week ago