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
Using R language: Given a vector or list of numbers, call this variable x , write...
Using R language: Given a vector or list of numbers, call this variable x , write down the code that will create a new vector, y , where all the odd number entries are set to 0. In other words, the first, third, fifth, etc entries should all be 0.
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...
Write a java program using the following instructions: Write a program that determines election results. Create...
Write a java program using the following instructions: Write a program that determines election results. Create two parallel arrays to store the last names of five candidates in a local election and the votes received by each candidate. Prompt the user to input these values. The program should output each candidates name, the votes received by that candidate, the percentage of the total votes received by the candidate, and the total votes cast. Your program should also output the winner...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT