Question: Consider the following LC - 3 assembly language program: . ORIG x 3 0 0 0 L 1 LEA R 1 , L 1 AND
Consider the following LC assembly language program:
ORIG x
L LEA R L
AND R R x
ADD R R x
LD R P
L LDR R R xC
OUT
ADD R R #
BRz GLUE
ADD R R R
BR L
GLUE HALT
PFILL xB
STRINGZ HBoeoakteSmtHaotrens
END
Assemble this program and load it into memory in the LC simulator.
a What binary number is stored in memory location x Your answer should be
in binary.
b What is the address of the instruction that is executed immediately after the
instruction at address x is executed?
c What is the address of the instruction that is executed prior to the instruction at
address x
d What is the output of this program?
e In words or less, what does this program do
The following specification, program, and discussion come from Example of the
textbook.
Write a game program to do the following: A person is sitting at a keyboard. Each
time the person types a capital letter, the program outputs the lowercase version of
that letter. If the person types a the program terminates.
The following LC assembly language program will do the job.
ORIG x
LD R TERM ; Load
LD R ASCII ; Load ASCII difference
AGAIN TRAP x ; Request keyboard input
ADD R R R ; Test for terminating character
BRz EXIT
ADD R R R ; Change to lowercase
TRAP x ; Output to the monitor
BRnzp AGAIN ; and do it again!
TERM FILL xFFC ; FFC is negative of ASCII
ASCII FILL x ; ASCII upperlower difference
EXIT TRAP x ; Halt
END
The program executes as follows: The program first loads constants xFFC and x
into R and R The constant xFFC which is the negative of the ASCII code for
is used to test the character typed at the keyboard to see if the user wants to continue
playing. The constant x is the zeroextended difference between the ASCII code
for a capital letter and the ASCII code for that same letters lowercase representation.
For example, the ASCII code for A is x and the ASCII code for a is x The ASCII
codes for Z and z are xA and xA respectively.
Then TRAP x is executed, it invokes the keyboard input service routine. When the
service routine is finished, control returns to the application program, and R now
contains the ASCII code of the character typed. The ADD and BRz instructions test
for the terminating character If the character typed is not the ASCII
uppercaselowercase difference x is added to the input ASCII code, storing the
result in R Then a TRAP to the monitor output service routine is called. This causes
the lowercase representation of the same letter to be displayed on the monitor. When
control returns to the application program, an unconditional BR to AGAIN is
executed, and another request for keyboard input appears.
The correct operation of this program assumes that the person sitting at the keyboard
only types capital letters or the character But what if the person types something
else, like a lowercase letter, or the character $ A better program would test the
character typed to be sure it really is a capital letter from among the capital letters
in the English alphabet, and if it is not, it would take appropriate corrective action.
Your job: Augment this program to add a test for bad data. In other words, modify
this program so that it will not only produce the lowercase letter for any uppercase
letter typed, but will also be able to tell when an invalid character is typed and then
respond appropriately.
Assume that an integer greater than and less than is deposited in memory
location A by another module before the program below is executed.
ORIG x
AND R R #
LD R A
NOT R R
ADD R R #
ADD R R #
;
REMOD JSR MOD
BRz STORE
;
ADD R R R
BRz STORE
ADD R R #
BR REMOD
;
STORE ADD R R #
STORE ST R RESULT
TRAP x
;
MOD ADD R R #
NOT R R
ADD R R #
DEC ADD R R R
BRp DEC
RET
;
A BLKW #
RESULT BLKW #
END
In words or fewer, what does the above program do
The program below, when complete, should print the following to the monitor:
ABCFGH
Insert instructions at ad that will complete the program.
ORIG x
LEA R TESTOUT
BACK LDR R R #
BRz NEXT
TRAP x
a
BRnzp BACK
;
NEXT LEA R TESTOUT
BACK LDR R R #
BRz NEXT
JSR SUB
ADD R R #
BRnzp BACK
;
NEXTb
;
SUBc
K LDI R DSR
d
STI R DDR
RET
DSR FILL XFE
DDR FILL XFE
TESTOUT STRINGZ ABC
END
Describe and explain the Trap Vector Table.
We might see code at the beginning and end of a TRAP service routine that looks
like this:
ST R SaveR
ST R SaveR
LD R SaveR
LD R SaveR
Explain.
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
