Question: TRAPS and the RUNTIME STACK Programming Lab # 6 CEG 3 3 1 0 / 5 3 1 0 : Computer Organization PURPOSE In this
TRAPS and the RUNTIME STACK
Programming Lab #
CEG : Computer Organization
PURPOSE
In this lab you will learn how to write your own trap service routines. You will also learn how to write
subroutines that utilize the runtime stack.
ASSIGNMENT
Using the LC simulator, you will construct an assemblylevel program that prompts for options when
working with a linked list, like printing, adding, and removing items from the list. A sample execution and
equivalent C program are included.
PART
To implement input.asm you must do the following:
You must read a user's input of digit decimal numbers. You are encouraged to reuse code you
wrote for Lab
Once you have the decimal value you must load the final value into R
For example: if a user types the ASCII characters then at the end of your TRAP call R must
contain the value xF in hexadecimal.
This TRAP call should function properly even after being called multiple times, you will need to
call this TRAP function multiple times to complete this lab.
To implement output.asm you must do the following:
Using R you must print the decimal value loaded into R to the console
For example if the hex value in R is x then the console window should display the
characters
To allow these trap routines to be useful, you must add them to the trap vector table.
To add a trap service routine to the trap vector table, it must have its own unique starting
address x for input.asm and x for output.asm
This starting address must be added to the trap vector table x for input and x for output
You must submit multiple programs for your final lab submission
PART
Once your trap service routines are added to the trap vector table, you can implement the main program
loop of your linked list program.
Setup your runtime stack for the main function as described in the sample C code
Do not create custom subroutines for printf, scanf, malloc, or free. You must still be able
to print information to the user and read the users input.
Prompt the user to make a selection from the choices of print, add, remove, or quit.
If the user selects add or remove, prompt the user to type a number to add or remove.
Use your trap service routines to capture the value entered
Pass the value entered to your
If the user selects print, add, or remove setup your runtime stack to call the functions as
described in the sample C code.
Implement the assembly equivalent of the functions for print, add, and remove, from
the C code as subroutines.
Any required arguments must be passed to the functions through the runtime stack.
If the user quits, pop your runtime stack and halt the processor.
NOTE
You will have to submit multiple programs at least independent programs required ie main,
input, and output. Using more than programs is acceptable.
The add and remove functions must accept a double pointer a pointer to a pointer for your
linked list. This allows removal of the head of the linked list and the creation of the head of the
linked list when the head is nonexistent.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
