Question: Write a TOY program that reads, interactively, a number, multiplies that number by 4 = 22 and outputs the result. This means that the input

 Write a TOY program that reads, interactively, a number, multiplies thatnumber by 4 = 22 and outputs the result. This means that

Write a TOY program that reads, interactively, a number, multiplies that number by 4 = 22 and outputs the result. This means that the input and output has to happen through the standard input and output, the number to be multiplied is not already in the memory of the computer. The table of instruction for the TOY machine appears at below. TOY reference card opcode operation format pseudo-code 0 halt - halt add RR R[d] = R[s] + R[t] Format RR 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 subtract bitwise and Opcode destination d sources sourcet bitwise xor RR RR RR RR RR R[d] = R[s] - R[t] R[d] = R[s] & R[t] R[d] =R[s] ^ R[t] R[d] =R[s] > R[t] shift left shift right load addr A R[d] = addr Format A load 151413 12 11 10 9 8 7 6 5 4 3 2 1 0 A A R[d] = M[addr] Maddr] = R[d] store opcode destination d address ADDR load indirect RR R[d] = M[R[t]] store indirect branch zero branch RR A A RR A M[R[t]] = R[d] if (R[d] == 0) PC = addr if (R[d] >0) PC = addr PC = R[d] R[d] = PC + 1; PC = addr R[O] is always 0. STANDARD INPUT Load from FF. STANDARD OUTPUT Store to FF. jump register jump and link F Write a TOY program that reads, interactively, a number, multiplies that number by 4 = 22 and outputs the result. This means that the input and output has to happen through the standard input and output, the number to be multiplied is not already in the memory of the computer. The table of instruction for the TOY machine appears at below. TOY reference card opcode operation format pseudo-code 0 halt - halt add RR R[d] = R[s] + R[t] Format RR 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 subtract bitwise and Opcode destination d sources sourcet bitwise xor RR RR RR RR RR R[d] = R[s] - R[t] R[d] = R[s] & R[t] R[d] =R[s] ^ R[t] R[d] =R[s] > R[t] shift left shift right load addr A R[d] = addr Format A load 151413 12 11 10 9 8 7 6 5 4 3 2 1 0 A A R[d] = M[addr] Maddr] = R[d] store opcode destination d address ADDR load indirect RR R[d] = M[R[t]] store indirect branch zero branch RR A A RR A M[R[t]] = R[d] if (R[d] == 0) PC = addr if (R[d] >0) PC = addr PC = R[d] R[d] = PC + 1; PC = addr R[O] is always 0. STANDARD INPUT Load from FF. STANDARD OUTPUT Store to FF. jump register jump and link F

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 Accounting Questions!