0% found this document useful (0 votes)
48 views

Homework # 3 Karimah Najiyah 1206202305

Karimah Najiyah 1206202305 completed homework assignment #3 which involved: 1. Developing a program for a stack machine to solve the equation X = (A2 + B) - (C/(D x E2)) using instructions like PUSH, POP, ADD, SUB, MUL, and DIV. 2. Developing a similar program for a one address machine using instructions like LOAD, STORE, ADD, SUB, MUL, and DIV. 3. Determining the contents of an accumulator for a one-address machine after a series of LOAD instructions like LOAD IMMEDIATE, LOAD DIRECT, and LOAD INDIRECT using a given memory state.

Uploaded by

karimahnajiyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Homework # 3 Karimah Najiyah 1206202305

Karimah Najiyah 1206202305 completed homework assignment #3 which involved: 1. Developing a program for a stack machine to solve the equation X = (A2 + B) - (C/(D x E2)) using instructions like PUSH, POP, ADD, SUB, MUL, and DIV. 2. Developing a similar program for a one address machine using instructions like LOAD, STORE, ADD, SUB, MUL, and DIV. 3. Determining the contents of an accumulator for a one-address machine after a series of LOAD instructions like LOAD IMMEDIATE, LOAD DIRECT, and LOAD INDIRECT using a given memory state.

Uploaded by

karimahnajiyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Homework # 3

Karimah Najiyah 1206202305

1. Develop a program for a stack machine (zero address machine/instruction), to solve an equation X = (A2 + B) - (C/(D x E2)). A,B,C,D dan E are variables, located in memory (integers). The available instructions are : PUSH M and POP M (M is a variabel), ADD, SUB, MUL and DIV. Answer: 1. PUSH A 2. PUSH A 3. MUL 4. PUSH B 5. ADD 6. PUSH C 7. PUSH D 8. PUSH E 9. PUSH E 10. MUL 11. MUL 12. DIV 13. SUB 14. POP X 2. Also develop a program to solve the same equation as in problem number 1, for one address machine/instruction. The available instructions are : LOAD M, STORE M, ADD M, SUB M, MUL M dan DIV M ; where M is a variable located in Main Memory. Answer : Instruction LOAD E MUL E MUL D STORE X LOAD C DIV X STORE X LOAD A MUL A ADD B SUB X STORE X Comments AC AC AC X AC AC X AC AC AC AC X

E AC*E AC*D AC C C/X AC A AC*A AC+B AC-X AC

3. Say that we have memory state (address and its content) as the following : Word 20 contains 40. Word 30 contains 50. Word 40 contains 60 and Word 50 contains 70. If we have one-address machine with an accumulator, determine the content of the accumulator after the executios of the following instructions : a. LOAD IMMEDIATE 40 ? b. LOAD DIRECT 50 ? c. LOAD INDIRECT 30 ? d. LOAD DIRECT 40 ? e. LOAD DIRECT 20 ? f. LOAD INDIRECT 20 ? Answer : a. LOAD #40 b. LOAD 50 c. LOAD @30 d. LOAD 40 e. LOAD 20 f. LOAD @20 ACC=40 ACC=70 ACC=70 ACC=60 ACC=40 ACC=60

You might also like