{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

tutLN5soln - FIT1001 Solutions to FIT1001 Tutorials for LN5...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
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
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
* 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.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern