Midterm Review Number systems Binary number Hexadecimal number

  • Slides: 15
Download presentation
Midterm Review § Number systems Binary number Hexadecimal number Floating numbers and IEEE 754

Midterm Review § Number systems Binary number Hexadecimal number Floating numbers and IEEE 754 standard N = -1 S x 1. Fraction x 2 exponent – 127 Two’s complement numbers 6/13/2021 CMPUT 229 1

§ Number Systems Signed extension Big and little endianess Binary arithmetic and overflow detection

§ Number Systems Signed extension Big and little endianess Binary arithmetic and overflow detection 6/13/2021 CMPUT 229 2

§ MIPS Architecture Instruction archtecture Reduced Instruction Set software instruction set hardware 6/13/2021 CMPUT

§ MIPS Architecture Instruction archtecture Reduced Instruction Set software instruction set hardware 6/13/2021 CMPUT 229 3

§ MIPS Architecture Memory registers: fast Microprocessor (CPU) Registers ALU 6/13/2021 CMPUT 229 words

§ MIPS Architecture Memory registers: fast Microprocessor (CPU) Registers ALU 6/13/2021 CMPUT 229 words of storage separate from memory ALU (Arithmetic and Logic ops Unit) does computations mainly on register values 4

§ MIPS Instructions Functionalities • Arithmetic and logic operations • Load, store, and data

§ MIPS Instructions Functionalities • Arithmetic and logic operations • Load, store, and data movement • Control flow (jump and branch) • System call • Exception 6/13/2021 CMPUT 229 5

§ MIPS instructions Format R- format I- format J- format 6 bits 5 bits

§ MIPS instructions Format R- format I- format J- format 6 bits 5 bits 6 bits opcode=0 reg reg shift function 6 bits 5 bits 16 bits opcode reg immediate operand 6 bits 26 bits opcode address operand 6/13/2021 CMPUT 229 6

§ Address Modes Register addressing Base + index addressing Immediate addressing PC-relative addressing 6/13/2021

§ Address Modes Register addressing Base + index addressing Immediate addressing PC-relative addressing 6/13/2021 CMPUT 229 7

§ Control flow MIPS facilities • Branch and jump Selection (if-the-else) Loops • Pre-test

§ Control flow MIPS facilities • Branch and jump Selection (if-the-else) Loops • Pre-test • Post-test 6/13/2021 CMPUT 229 8

§ Data and Data Structures Local variables Global variables Arrays Pointers 6/13/2021 CMPUT 229

§ Data and Data Structures Local variables Global variables Arrays Pointers 6/13/2021 CMPUT 229 9

§ System stack $sp Push operation Pop operation § Global area $gp 6/13/2021 CMPUT

§ System stack $sp Push operation Pop operation § Global area $gp 6/13/2021 CMPUT 229 10

§ Function and procedure calls Advantages • Code reuse • Structured programming • Top-down

§ Function and procedure calls Advantages • Code reuse • Structured programming • Top-down system design Challenges • Return address • Pass information back and forth • Side effects of function calls • A function may modify values of • registers/global variables 6/13/2021 CMPUT 229 11

§ MIPS facilities for function calls System stack and $sp JAL and $RA •

§ MIPS facilities for function calls System stack and $sp JAL and $RA • Jump and link instruction associated with the special register $RA § MIPS conventions for function calls $a registers for passing values to functions $v registers for returning values to the caller The caller saves $t registers The callee saves $s registers 6/13/2021 CMPUT 229 12

§ CMPUT 229 conventions Outlined in the course web pages Compatible with MIPS conventions,

§ CMPUT 229 conventions Outlined in the course web pages Compatible with MIPS conventions, except that • Function with 3 or more parameters must be passed through a stack frame • The callee saves all modified registers other than $t registers • All local variables, except the loop control variables, must be allocated on stack 6/13/2021 CMPUT 229 13

§ Sample Programming Minmax. s • Data array • Pass values by pointers fib.

§ Sample Programming Minmax. s • Data array • Pass values by pointers fib. a and fib_stack. a • How to pass values by registers and by stack Tow of Hanoi • Iterative program • Recursive progra 6/13/2021 CMPUT 229 14

§ Notes about the midterm as well as the final One may bring one

§ Notes about the midterm as well as the final One may bring one piece of paper • You may write anything on it, • You may use printer to print, • You may print something on both sides 6/13/2021 CMPUT 229 15