This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: FIT1001 ISA Solutions to FIT1001 Tutorials for LN5 Instruction Set Architecture * Exercise 1 Calculation of Arithmetic Expressions. Consider the arithmetic expression r = ( a + b + c ) /a . Generate the instructions required to calculate this expression in the following architectures. 1. Stack (first represent this expression in postfix notation). SOLUTION Postfix notation: ab+c+a/ Stack operations: PUSH A PUSH B ADD PUSH C ADD PUSH A DIV POP R 2. Accumulator. SOLUTION LOAD A ADD B ADD C DIV A STORE R 3. GPR (load/store). SOLUTION LOAD $R1,A LOAD $R2,B ADD $R3,$R1,$R2 LOAD $R1,C ADD $R3,$R1,$R3 LOAD $R1,A DIV $R3,$R3,$R1 STORE $R3,R Note: in a load/store architecture, the first operand (register) is normally the destination of a load and the source of a store. However, for this unit, students are allowed to use the same convention as for the other instructions. 1 * Exercise 2 Operand organization. Consider the arithmetic expression Z = ( X + Y ) × U . Using the assembly language instructions LOAD, STORE, ADD and MULT, write a program that performs these operations, assuming: 1. an accumulator architecture. SOLUTION: LOAD X ADD Y MULT U STORE Z 2. a two operand load/store GPR architecture. Indicate the destination of the result. SOLUTION: LOAD $R1,X LOAD $R2,Y ADD $R1,$R2 // result goes to $R1 LOAD $R2,U MULT $R1,$R2 // result goes to $R1 STORE $R1,Z Note: in a load/store architecture, the first operand (register) is normally the destina- tion of a load and the source of a store. 3. a three operand register-memory GPR architecture. SOLUTION 1: two registers and one memory address. LOAD $R1,X ADD $R2,$R1,Y // result goes to $R2 MULT $R2,$R2,U // result goes to $R2 (you can reuse $R2) STORE $R2,Z // result goes to Z Note: Here too I adopted the above convention for load and store. SOLUTION 2: one register and two memory addresses. ADD $R2,X,Y // result goes to $R2 MULT Z,$R2,U // result goes to Z * Exercise 3 Addressing modes....
View Full Document
This note was uploaded on 08/15/2010 for the course FIT 1001 taught by Professor Egerton during the Three '10 term at Monash.
- Three '10