Docsity

LC-3 Assembly Language Programming: Subroutine Calls and Stack Operations, Slides of Computer Science

Toggle sidebar
bg1
HW 9
1) a) Modify your program for HW 8 and use Subroutine Calls rather than TRAPS
to execute the TRAP routines.
a) Load your program into the simulator and use breakpoints and single stepping
to observe the operation of the TRAP Routines you used as pre-written
subroutines.
b) Document your observations with some simulator snapshots. Of course,
identify why you chose these snapshots and what the snapshots are
displaying.
2) Write an LC-3 assembly language program to:
a) Define your stack to begin at xFE00.
b) Read and echo two one-digit hexadecimal numbers from the keyboard (with
input message). They need to be small enough that the sum of them is still
one hexadecimal digit.
c) Push the two hexadecimal numbers onto the stack using your subroutine
which provides the PUSH and POP functions. (Your subroutine doesn’t have
to check for overflow and underflow). The PUSH’ed or POP’ed value is
passed using register R0.
d) Call another subroutine, call it ADD, which POPs the two hexadecimal
numbers off of the stack, adds them, and PUSH’es the sum onto the stack.
e) Finally, your program will POP the sum from the stack and print it to the
console (with labeling).
f) Load your program into the simulator and use breakpoints and single stepping
to observe the operation of your program and subroutines.
g) Document your observations with some simulator snapshots. Of course,
identify why you chose these snapshots and what the snapshots are
displaying.
Docsity.com

Partial preview of the text

Download LC-3 Assembly Language Programming: Subroutine Calls and Stack Operations and more Slides Computer Science in PDF only on Docsity!

HW 9

  1. a) Modify your program for HW 8 and use Subroutine Calls rather than TRAPS to execute the TRAP routines.

a) Load your program into the simulator and use breakpoints and single stepping to observe the operation of the TRAP Routines you used as pre-written subroutines.

b) Document your observations with some simulator snapshots. Of course, identify why you chose these snapshots and what the snapshots are displaying.

  1. Write an LC-3 assembly language program to:

a) Define your stack to begin at xFE00.

b) Read and echo two one-digit hexadecimal numbers from the keyboard (with input message). They need to be small enough that the sum of them is still one hexadecimal digit.

c) Push the two hexadecimal numbers onto the stack using your subroutine which provides the PUSH and POP functions. (Your subroutine doesn’t have to check for overflow and underflow). The PUSH’ed or POP’ed value is passed using register R0.

d) Call another subroutine, call it ADD, which POPs the two hexadecimal numbers off of the stack, adds them, and PUSH’es the sum onto the stack.

e) Finally, your program will POP the sum from the stack and print it to the console (with labeling).

f) Load your program into the simulator and use breakpoints and single stepping to observe the operation of your program and subroutines.

g) Document your observations with some simulator snapshots. Of course, identify why you chose these snapshots and what the snapshots are displaying.

Docsity.com