{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

arithmem.pdf - 308-273 C/Assembler Arithmetic and Memory...

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

View Full Document Right Arrow Icon
COMP-273 Arith/Mem (1) Slides From Patterson’s 61C 308-273 C/Assembler Arithmetic and Memory Access Kaleem Siddiqi
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
COMP-273 Arith/Mem (2) Slides From Patterson’s 61C Overview ° C operators, operands ° Variables in Assembly: Registers ° Addition and Subtraction in Assembly ° Memory Access in Assembly
Background image of page 2
COMP-273 Arith/Mem (3) Slides From Patterson’s 61C Review C Operators/Operands ° Operators: + , - , * , / , % (mod); 7/4==1 , 7%4==3 ° Operands: Variables: fahr , celsius Constants: 0 , 1000 , -17 , 15.4 ° Assignment Statement: Variable = expression Examples: celsius = 5*(fahr-32)/9; a = b+c+d-e;
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
COMP-273 Arith/Mem (4) Slides From Patterson’s 61C Assembly Design: Key Concepts ° Assembly language is essentially directly supported in hardware, therefore ... ° It is kept very simple! Limit on the type of operands Limit on the set operations that can be done to absolute minimum - if an operation can be decomposed into a simpler operation, don’t include it
Background image of page 4
COMP-273 Arith/Mem (5) Slides From Patterson’s 61C Assembly Variables: Registers (1/3) ° Unlike HLL, assembly cannot use variables Why not? Keep Hardware Simple ° Assembly Operands are registers limited number of special locations built directly into the hardware operations can only be performed on these! ° Benefit: Since registers are directly in hardware, they are very fast
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
COMP-273 Arith/Mem (6) Slides From Patterson’s 61C Assembly Variables: Registers (2/3) ° Drawback: Since registers are in hardware, there are a predetermined number of them Solution: MIPS code must be very carefully put together to efficiently use registers ° 32 registers in MIPS Why 32? Smaller is faster ° Each MIPS register is 32 bits wide Groups of 32 bits called a word in MIPS
Background image of page 6
COMP-273 Arith/Mem (7) Slides From Patterson’s 61C Assembly Variables: Registers (3/3) ° Registers are numbered from 0 to 31 ° Number references: $0, $1, $2, … $30, $31 ° By convention, each register also has a name to make it easier to code: $16 - $22 è $s0 - $s7 (correspond to C variables) $8 - $15 è $t0 - $t7 (correspond to temporary variables) ° In general, use register names to make your code more readable
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
COMP-273 Arith/Mem (8) Slides From Patterson’s 61C Comments in Assembly ° Another way to make your code more readable: comments! ° Hash (#) is used for MIPS comments anything from hash mark to end of line is a comment and will be ignored ° Note: Different from C.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}