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

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

View Full Document Right Arrow Icon
CS 230 - Winter 2011 4-1 CS 230 – Introduction to Computers and Computer Systems Module 4 – Build and Execute Martin Karsten mkarsten@cs.uwaterloo.ca
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 2011 4-2 Overview execution approaches scanning – regular expressions parsing – context-free grammars linking and loading
Background image of page 2
CS 230 - Winter 2011 4-3 Classical Tool Chain Compiler translates high level language into assembly program. Assembler translates assembly program into machine code in object file. Linker combines multiple object files of machine code into program file. Loader loads program file into main memory. Library is special object file that can be added to program file during linking or loading.
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 2011 4-4 Other Execution Approaches Interpretation execute source code directly execute binary code by software Byte Code compile to intermediate binary representation Just-In-Time Compilation compile during runtime
Background image of page 4
CS 230 - Winter 2011 4-5 Compiler program translation from source language to target language usually: high-level to low-level (assembly) complex to simple typically followed by assembler to generate machine code
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 2011 4-6 Assembler line by line translation from one assembly instruction to one machine code instruction translate pseudo-instructions insert data for .word directive and possibly other directives. .. ignore comments and blank lines compute address of each label
Background image of page 6
CS 230 - Winter 2011 4-7 Instruction Format – Jump oooo ooii iiii iiii iiii iiii iiii iiii o – opcode i – jump target instructions with large constant operand jump target = high4(PC) + (i << 2) combine highest 4 bits of current PC with immediate operand multiplied by 4
Background image of page 7

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

View Full DocumentRight Arrow Icon
CS 230 - Winter 2011 4-8 Machine Code – Jump jal 35528 0000 11 00 0000 0000 0010 0010 1011 0010
Background image of page 8
CS 230 - Winter 2011 4-9 Instruction Format – Immediate oooo ooss ssst tttt iiii iiii iiii iiii o – opcode s,t - registers i – immediate operand instructions with register and constant operand
Background image of page 9

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

View Full DocumentRight Arrow Icon
CS 230 - Winter 2011 4-10 Machine Code – Immediate lw $1 , 23 ( $2 ) 1000 11 00 010 0 0001 0000 0000 0001 0111
Background image of page 10
CS 230 - Winter 2011 4-11 Instruction Format – Register 0000 00ss ssst tttt dddd d000 00ff ffff opcode 000000 s,t,d – registers f – function instructions with all operands in registers
Background image of page 11

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

View Full DocumentRight Arrow Icon
CS 230 - Winter 2011 4-12 Machine Code – Register add $1 , $2 , $3 0000 00 00 010 0 0011 0000 1 000 00 10 0000 mult $2 , $3 0000 00 00 010 0 0011 0000 0000 00 01 1000
Background image of page 12
CS 230 - Winter 2011 4-13 Stack Frame stack pointer: bottom of stack, first free field stack pointer might vary during routine set up stack for subroutine call at routine entry, frame pointer is set e.g. to stack pointer at that time frame pointer providers a constant base to access local variables and arguments use offset in lw $t, i($fp) instruction
Background image of page 13

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

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

Page1 / 67

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

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

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