mod02 - CS 230 Introduction to Computers and Computer...

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

View Full Document Right Arrow Icon
CS 230 - Winter 2012 2-1 CS 230 – Introduction to Computers and Computer Systems Module 2 – Assembly Language (Slides based on materials prepared by Martin Karsten ) CS 230 - Winter 2012 2-2 Overview ! assembly language: MIPS ! arithmetic operations ! data movement ! conditional execution ! subroutines
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS 230 - Winter 2012 2-3 Machine Code ! binary code – comprised of 0s and 1s ! “direct” execution by processor ! program (bits) grouped into instructions ! fixed vs. variable length ! operation code (opcode) + operands ! instructions control processor ± opcode designates operation ± operands designate data CS 230 - Winter 2012 2-4 Assembly Language ! human-readable “programming language” ! very simple compared to, e.g., Scheme, Python ! almost direct mapping to machine code, except: ! labels ! data declaration ! pseudo instructions ! compilation by assembler program ! into machine code
Background image of page 2
CS 230 - Winter 2012 2-5 Instruction Set ! repertoire of instructions ! different processors have different sets ! many commonalities ! depending on use cases ! scalar processor – one data item at a time ± typical workstation/laptop/etc. CPU ! vector processor – array of data (vector) ± e.g., graphics processor (GPU) ! hybrids. .. CS 230 - Winter 2012 2-6 Turing Completeness ! well-defined theoretical concept ! fundamental capabilities of instruction set ! minimum requirements ! while or if/goto & change memory locations ! typical programming languages / instruction sets are Turing complete ! ... vs. data description languages, e.g. XML
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS 230 - Winter 2012 2-7 MIPS Architecture ! MIPS: M icroprocessor without I nterlocked P ipeline S tages ! interlocking? ! pipeline? ! details later (Module 3) ! multiple revisions, systems, and compilers => not just a single standard CS 230 - Winter 2012 2-8 MIPS Assembly Language ! each instruction takes 32 bit = 4 bytes = word ! arithmetic instructions operate on registers ! separate memory load and store ! 32 registers available, 32 bit wide ! instructions have up to 3 operands: ! 1 st operand is destination ! 2 nd and 3 rd are sources ! same register can be source and destination
Background image of page 4
CS 230 - Winter 2012 2-9 MIPS Machine Code ! see reference sheet, additions: ! Add Immediate addi $t, $s, i 0010 00ss ssst tttt iiii iiii iiii iiii $t = $s + i ! Jump and Link jal x 0000 11xx xxxx xxxx xxxx xxxx xxxx xxxx $31 = pc + 4; pc = x CS 230 - Winter 2012 2-10 Special Registers ! PC – program counter current location in machine code ! incremented by 4 for each instruction ! $0 – constant 0 ! conventions (more later) ! $28 – global pointer ($gp) ! $29 – stack pointer ($sp) ! $30 – frame pointer ($fp) ! $31 – return address ($ra)
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS 230 - Winter 2012 2-11 MIPS Assembly Language ! two addressing modes ! register: operands in registers ! immediate: one operand is a 16-bit constant ! memory: 32-bit address space ! relative & absolute memory load/store ! relative & absolute branch instructions !
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/01/2012 for the course CS 230 taught by Professor Bb during the Spring '11 term at Waterloo.

Page1 / 41

mod02 - CS 230 Introduction to Computers and Computer...

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

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