slide2 - Computer Architecture CPSC 321 E. J. Kim A...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Computer Architecture CPSC 321 E. J. Kim 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) MIPS R3000 Instruction Set Architecture ° Machine Environment 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: Review C Operators/Operands • Operators: + , - , * , / , % (mod); ( 7/4==1 , 7%4==3) • Operands: • Variables: fahr , celsius • Constants: , 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; 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; 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 multiple instructions 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 Compilatio n ° How to turn the notation that programmers prefer into notation computer understands? ° Program to translate C 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 Compilation 2 ° Example: compile by hand this C code: f = (g + h) - (i + j); ° First sum of g and h. Where to put result? add f, g, h # f contains g+h ° Now sum of i and j. Where to put result? Cannot use f ! 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) 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 line of C produces many assembly instructions One reason why people program in C vs. Assembly; fewer lines of code Other reasons? (many!) Assembly Design: Key Concepts • Assembly language is essentially directly supported...
View Full Document

This note was uploaded on 03/23/2011 for the course CPSC 350 taught by Professor Staff during the Spring '08 term at Texas A&M.

Page1 / 49

slide2 - Computer Architecture CPSC 321 E. J. Kim A...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online