Question

In: Computer Science

Using MARIE RTL, write RTL commands for CALL X and RET Instructions, assume there is an...

Using MARIE RTL, write RTL commands for CALL X and RET Instructions, assume there is an additional register called SP (Stack Pointer)

Solutions

Expert Solution

CALL X ,

here X is the address of subroutine. When call is executed, the control transfers to the subroutine which has the starting address X. Here the content of the PC(which contains the address of the next instruction to be fetched) is to be stored in into the stack. The stack top address is stored in the register SP. i.e, PC content is to be stored into address given by SP. Also PC is to be stored with the address of the subroutine X.

So the operations are: (RTL command for CALL X)

   Execute:                  MBR←PC

                                  MAR ←SP

                                  M[MAR] ←MBR

                                  PC ← X                 (IR[11..0]) will contain address after fetch cycle)

The ret instruction transfers control to the return address located on the stack.The stack pointer SP contains the return address. This address is to be loaded into the PC so that program execution can resume from the instruction after the CALL X.

RET: (RTL command for RET)

                                   PC←SP

                         

The instruction cycle of CALL X

CALL X

Fetch:                       MAR ← PC

MBR ← M[MAR]

   IR ← MBR

PC ← PC + 1

Decode:                    Decode IR[15..12]

                                   MAR ← IR[11..0] // this step is not needed

Get op:                      not needed

Execute:                    MBR←PC

                                  MAR ←SP

                                  M[MAR] ←MBR

                                  PC ← IR[11..0]

Store result: not needed

Initially, PC contains the address of CALL X from where the instruction is to be fetched.

     During fetch cycle, the address in PC loaded into MAR (MAR ← PC) . instruction is fetched from the memory location specified in MAR and stored in MBR(MBR ← M[MAR]). Next instruction in MBR is loaded into IR(IR ← MBR). Meanwhile PC gets incremented to point to next instruction.( PC ← PC + 1)

During Decode cycle, the opcode IR[15..12] is decoded and IR[11..0] contains address X.

During execute cycle, PC content gets saved into memory stack address given by SP and PC is loaded with address X (IR[11..0]).

Instruction cycle of RET

Fetch:                       MAR ← PC

MBR ← M[MAR]

   IR ← MBR

PC ← PC + 1

Decode:                    Decode IR[15..12]

                                   MAR ← IR[11..0] // this step is not needed

Get op:                      not needed

Execute:                    PC←SP

                                 

Store result: not needed


Related Solutions

For the PIC16F887, using the execution delay of instructions, write assembly language commands to implement a...
For the PIC16F887, using the execution delay of instructions, write assembly language commands to implement a delay of 3 seconds
Write a MARIE program that implements the following logic. If X < Y Then X =...
Write a MARIE program that implements the following logic. If X < Y Then X = X + Y Else Y = 2X Assume the two numbers are X and Y and are entered by the user. Provide prompts to the user to enter the numbers and provide a meaningful output to the screen.
(Write/Design) both the RTL and Testbench using the Verilog HDL language of the five input majority...
(Write/Design) both the RTL and Testbench using the Verilog HDL language of the five input majority using the structure modeling approach. NOTE: Design means RTL code and Testbench covering all possible corner cases
Write a verilog code for 8-bit signed multiplication using Booth algorithm and represent the RTL view...
Write a verilog code for 8-bit signed multiplication using Booth algorithm and represent the RTL view for code
Using the MARIE computer assembly language, write a program that computes the following expression: z =...
Using the MARIE computer assembly language, write a program that computes the following expression: z = a * b * c. The computer will read in the input values a, b, and c from the keyboard and the final result (z) have to be displayed. In addition, every time an input value is read in, it must be displayed on the screen. Remember that the instruction set does not have an instruction to execute multiplication. Note: If any of the...
Write R commands for below queries, assume the data is in file named input.csv. Also explain...
Write R commands for below queries, assume the data is in file named input.csv. Also explain your answer id name salary start_date dept 1 Rick 623.3 1/01/2012 IT 2 Dan 515.2 23/09/2013 Operations 3 Michelle 611 15/11/2014 IT 4 Ryan 729 11/05/2014 HR 5 Gary 843.25 27/03/2015 Finance 6 Nina 578 21/05/2013 IT 7 Simon 632.8 30/07/2013 Operations 8 Guru 722.5 17/06/2014 Finance Open the file and Get the max salary from data frame Get the detail of person having...
Exercise #1:  Write MARIE assembly language code to input 3 values into variables x, y, and z,...
Exercise #1:  Write MARIE assembly language code to input 3 values into variables x, y, and z, calculate x + y -z, and outputs the result. Run your code in the simulator and submit a screen shot of your program run and the code. //x + y -z ORG 100     INPUT     STORE X     INPUT     STORE Y     INPUT     STORE Z     LOAD X     ADD Y     SUBT Z     OUTPUT     Halt X, Dec 0 Y, DEC 0 Z, DEC 0 Exercise #2: Write MARIE assembly...
USING R STUDIO- Write the r commands for the following. 1. Non-Linear Models 1.1 Load the...
USING R STUDIO- Write the r commands for the following. 1. Non-Linear Models 1.1 Load the {ISLR} and {GGally} libraries. Load and attach the College{ISLR} data set. [For you only]: Open the College data set and its help file and familiarize yourself with the data set and its fields. 1.2 Inspect the data with the ggpairs(){GGally} function, but do not run the ggpairs plots on all variables because it will take a very long time. Only include these variables in...
USING PYTHON Write a program to create a number list. It will call a function to...
USING PYTHON Write a program to create a number list. It will call a function to calculate the average values in the list. Define main ():                        Declare variables and initialize them                        Create a list containing numbers (int/float)                        Call get_avg function that will return the calculated average values in the list.                                       Use a for loop to loop through the values in the list and calculate avg                        End main()
Instructions: Write a program to calculate students’ average test scores and their grades. You may assume...
Instructions: Write a program to calculate students’ average test scores and their grades. You may assume the following input data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT