Question: An assembly language program contains the following two instructions. The assembler puts the translated version of the LDI instruction that follows into location 0 x

An assembly language program contains the following two instructions. The
assembler puts the translated version of the LDI instruction that follows into location
0x3025. After assembly is complete, what is the value of the hexadecimal number in
location 0x3025?
PLACE .FILL x45A7
LDI R3, PLACE
2. Create the symbol table entries generated by the assembler when translating the
following routine into machine code.
.ORIG x301C
ST R3, SAVE3
ST R2, SAVE2
AND R2, R2, #0
TEST IN
BRz TEST
ADD R1, R0, #-10
BRn FINISH
ADD R1, R0, #-15
NOT R1, R1
BRn FINISH
HALT
FINISH ADD R2, R2, #1
HALT
SAVE3.FILL x0000
SAVE2.FILL x0000
.END
3. Write an LC-3 assembly language program that counts the number of 1s in the
value stored in R0 and stores the result into R1. For example, if R0 contains
0001001101110000(which has six 1s), then after the program executes the result
stored in R1 would be 0000000000000110(in other words, 6).
4. Assemble and run the following LC-3 assembly language program. What does this
program do? This is asking for a high-level summary, not a breakdown of individual
instructions!
.ORIG x3000
LD R2, ZERO
LD R0, M0
LD R1, M1
LOOP BRz DONE
ADD R2, R2, R0
ADD R1, R1, #-1
BR LOOP
DONE ST R2, RESULT
HALT
RESULT .FILL x0000
ZERO .FILL x0000
M0.FILL x0004
M1.FILL x0803
.END
What value will be contained in RESULT after the program runs to completion?
5. Assemble and run the following LC-3 assembly language program. What does this
program do? This is asking for a high-level summary, not a breakdown of individual
instructions!
.ORIG x3000
AND R5, R5, #0
AND R3, R3, #0
ADD R3, R3, #8
LDI R1, A
ADD R2, R1, #0
AG ADD R2, R2, R2
ADD R3, R3, #-1
BRnp AG
LD R4, B
AND R1, R1, R4
NOT R1, R1
ADD R1, R1, #1
ADD R2, R2, R1
BRnp NO
ADD R5, R5, #1
NO HALT
B .FILL xFF00
A .FILL x4000
.END
6. The following is an LC-3 program that performs a function. Assume a sequence of
integers is stored in consecutive memory locations, one integer per memory location,
starting at the location 0x4000. The sequence terminates with the value 0x0000.
What does the following program do? This is asking for a high-level summary, not a
breakdown of individual instructions!
.ORIG x3000
LD R0, NUMBERS
LD R2, MASK
LOOP LDR R1, R0, #0
BRz DONE
AND R5, R1, R2
BRz L1
BRnzp NEXT
L1 ADD R1, R1, R1
STR R1, R0, #0
NEXT ADD R0, R0, #1
BRnzp LOOP
DONE HALT
NUMBERS .FILL x4000
MASK .FILL x8000
.END
7. Assume a sequence of nonnegative integers is stored in consecutive memory
locations, one integer per memory location, starting at location 0x4000. Each integer
has a value between 0 and 30,000(decimal). The sequence terminates with the value -
1(i.e.,0xFFFF). Assemble and run the following LC-3 assembly language program.
What does the program do? This is asking for a high-level summary, not a breakdown
of individual instructions!
.ORIG x3000
AND R4, R4, #0
AND R3, R3, #0
LD R0, NUMBERS
LOOP LDR R1, R0, #0
NOT R2, R1
BRz DONE
AND R2, R1, #1
BRz L1
ADD R4, R4, #1
BRnzp NEXT
L1 ADD R3, R3, #1
NEXT ADD R0, R0, #1
BRnzp LOOP
DONE TRAP x25
NUMBERS .FILL x4000
.END
8. Assemble and run the following LC-3 assembly language program. What does the
program do (in no more than 20 words)? This is asking for a high-level summary, not
a breakdown of individual instructions!
.ORIG x3000
AND R0, R0, #0
ADD R2, R0, #10
LD R1, MASK
LD R3, PTR1
LOOP LDR R4, R3, #0
AND R4, R4, R1
BRz NEXT
ADD R0, R0, #1
NEXT ADD R3, R3, #1
ADD R2, R2, #-1
BRp LOOP
STI R0, PTR2
HALT
MASK .FILL x8000
PTR1.FILL x4000
PTR2.FILL x5000
.END
9. What is the purpose of the .END pseudo-op? How does it differ from the HALT
instruction?
10. Write the machine language version of the following LC-3 Assembly language
program:
.ORIG x3005
LEA R2, DATA
LDR R4, R2, #0
LOOP ADD R4, R4, #-3
BRzp LOOP
TRAP x25
DATA .FILL x000B
.END
11. The following program fragment generates an error when you try to assemble it.
Identify the error and rewrite this fragment so that it doesnt have the bug but still
does the same thing.
ADD R3, R3, #30
ST R3, A
HALT
A .FILL #0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!