{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

slide2 - Com r Archite pute cture C C321 PS E J Kim C p ro...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Architecture CPSC 321 E. J. Kim
Background image of page 1

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

View Full Document Right Arrow Icon
A Translation Hierarchy High Level Language (HLL) programs first compiled (possibly into assembly), then linked and finally loaded into main memory. Assembler Assembly language program Compiler C program Linker Executable: Machine language program Loader Memory Object: Machine language module Object: Library routine (machine language)
Background image of page 2
MIPS R3000 Instruction Set Architecture ° MachineEnvironment Target ° Instruction Categories Load/Store Computational Jump and Branch Floating Point ( coprocessor ) OP Rs Rt Rd sa funct OP Rs Rt Immediate OP jump target 3 Instruction Formats: all 32 bits wide R0 - R31 PC HI LO Registers I: R: J:
Background image of page 3

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

View Full Document Right Arrow Icon
Review C Operators/Operands Operators: + , - , * , / , % (mod); ( 7/4==1 , 7%4==3) Operands: Variables: fahr , celsius Constants: 0 , 1000 , -17 , 15.4 In C (and most High Level Languages) variables declared and given a type first Example: int fahr, celsius; int a, b, c, d, e;
Background image of page 4
Assembly Operators ° Syntax of Assembly Operator 1) operation by name 2) operand getting result Register or Memory 3) 1st operand for operation 4) 2nd operand for operation ° Ex. add b to c and put the result in a: add a, b, c Called an Assembly Language Instruction ° Equivalent assignment statement in C: a = b + c;
Background image of page 5

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

View Full Document Right Arrow Icon
Assembly Operators/Instructions ° MIPS Assembly Syntax is rigid: 1 operation, 3 variables Why? Keep Hardware simple via regularity ° How to do the following C statement? a = b + c + d - e; ° Break into multipleinstructions add a, b, c # a = sum of b & c add a, a, d # a = sum of b,c,d sub a, a, e # a = b+c+d-e ° To right of sharp sign (#) is a comment terminated by end of the line. Applies only to current line. C comments have format /* comment */ , can span many lines
Background image of page 6
Compilatio n ° How to turn thenotation that programmers prefer into notation computer understands? ° Program to translateC statements into Assembly Language instructions; called a compiler ° Example: compile by hand this C code: a = b + c; d = a - e; ° Easy: add a, b, c sub d, a, e ° Big Idea: compiler translates notation from one level of computing abstraction to lower level
Background image of page 7

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

View Full Document Right Arrow Icon
Compilation 2 ° Example: compile by hand this C code: f = (g + h) - (i + j); ° First sum of g and h. Whereto put result? add f, g, h # f contains g+h ° Now sum of i and j. Where to put result? Cannot usef ! Compiler creates temporary variable to hold sum: t1 add t1, i, j # t1 contains i+j ° Finally produce difference sub f, f, t1 # f = (g+h)-(i+j)
Background image of page 8
Compilation -- Summary ° C statement (5 operands, 3 operators): f = (g + h) - (i + j); ° Becomes 3 assembly instructions (6 unique operands, 3 operators): add f,g,h # f contains g+h add t1,i,j # t1 contains i+j sub f,f,t1 # f=(g+h)-(i+j) ° In general, each lineof C produces many assembly instructions One reason why people program in C vs. Assembly; fewer lines of code Other reasons? (many!)
Background image of page 9

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

View Full Document Right Arrow Icon
Assembly Design: Key Concepts Assembly language is essentially directly supported in hardware, therefore ...
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}