a) Create the symbol table for the program. You may not need to use all rows. Yo
ID: 3817446 • Letter: A
Question
a) Create the symbol table for the program. You may not need to use all rows. You can add
more rows if needed.
Symbol
Address
b) Load this program and run it in PennSim. What is the value stored inside R4 at the end of
execution?
c) We now want to count the number of occurrences of the character "a" in the string "fat cat
in the hat". What changes do we need to make to the code above to successfully accomplish
this? Clearly indicate which lines of code you would change and explain why .
Symbol
Address
Problem 3 (6 points) This program counts the number of occurrences of the character "a" in the string "cats hats". Answer the questions below: ORIG x3000 SETUP LEA R3, INPUT LD R1 INPUT2 AND R4, R4, #0 LD R2, SIZE NEG NOT R1 R1 ADD R1, R1 1 LOOP LDR RO R3 0 ADD R3, R3 1 ADD RS, RO, R1 BRnp CONT ADD R4, R4 #1 ADD R2, R2 -1 CONT BRp LOOP HALT INPUT STRING z cats hats INPUT2 STRING "a" FILL x9 SIZE ENDExplanation / Answer
a)
b)
At the end of program ,the value in the register R4 will be 2.
Explanation :-
in program, in R1 register stored the value of a i.e the ascii value and negated it i.e -65.
Then, he stored each alphabet of the input into a register and subtracted their respective ascii value with r1 i.e 65. And,if the result is zero (only when the input alphabet is zero ) then only r4 register is incremented.
c)
We need to change 2 lines:-
WE need to change the INPUT variable value to the sentence ; we require because from here only the control will take alphabers and also we need to change the value of SIZE variable because the loop depends on the value of SIZE variable which is equal the characters of the input given.
SYMBOL ADDRESS SETUP 0x3000 NEG 0x3004 LOOP 0x3006 CONT 0x300B INPUT 0x300E INPUT2 0x300F SIZE 0x3010Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.