What is the psuedocode for the following program? This should be a TLC program t
ID: 663610 • Letter: W
Question
What is the psuedocode for the following program? This should be a TLC program that displays even number 0 through 18 and halt after 18...Please explain in pseudocode.
00 LOAD 09 = 109
01 SUBTRACT 13 = 413
02 STORE 99 = 299
03 READ = 901
04 STORE 98 = 298
05 READ = 901
06 STORE 97 = 297
07 LOAD 19 = 119
08 STORE 96 = 296
09 LOAD 97 = 197
10 BRANCHZ 17 = 617
11 SUBTRACT 99 = 499
12 STORE 97 = 297
13 LOAD 96 = 196
14 ADD 98 = 398
15 STORE 96 = 296
16 BRANCH 09 = 509
17 LOAD 96 = 196
18 PRINT = 902
19 STOP = 000
Explanation / Answer
For Pseudo code we need to understand the instructions meaning which is not so tough. we have 1 local register
XX LOAD 09 means putting the value of memory location 09 into the register.
XX ADD 98 adding the value of memory location 98 into the register
XX SUBTRACT 99 means adding the vlue of memory location 99 into the register
XX BRANCHZ 17 move to line 17 instruction if value in the register is equal to 0
XX BRANCH 09 move to line 09 independent of any condition
XX STORE 98 store the value of register in memory location 98
XX READ read the value from console into register
XX PRINT print the value of register
00 LOAD 09 = 109 represent
00 is memory location; LOAD 09 is instruction at this memory location; 109 is value of this memory location.
So Basically this program is printing the table of any number n till n*x where n and x are the input from the user at INSTRUCTION number 3 and 5 respectively.
00 LOAD 09 = 109
01 SUBTRACT 13 = 413
02 STORE 99 = 299
memory location 99 contains 1 after these three instructions as LOAD 09 puts 197 (value of memory location 09) into the register; SUBTRACT 13 subtract the value of register by 196 (value of memory location 13)
STORE 99 store the value of regitser into memory location 99 which is equal to 1.
memory location 98 have value enter by user;
memory location 97 have value enter by user;
memory location 96 have value equal to 0 as (LOAD 19 STORE 96 value of memory location is 0);
we have loop from memory location 09 to memort location 16 which will terminate when value of register 97 become 0;
rest step are trivial.
Pseudo code
print ('Enter the value of number whose table you want ( n ) ')
n = input()
print ('Enter the value of number upto which you want this number table (n * x) so you need to put value of x ')
x = input()
i = 0
while (x > 0){
print i;
i = i + n;
x = x-1;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.