Faculty of Computer Science © 2006 CMPUT 229 Why Computer Architecture? An Introduction to CMPUT 229.

Slides:



Advertisements
Similar presentations
Lecture 13: 10/8/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Advertisements

The University of Adelaide, School of Computer Science
Lecture 9: MIPS Instruction Set
Instructor: Tor Aamodt
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Chapter 2 — Instructions: Language of the Computer — 1 Branching Far Away If branch target is too far to encode with 16-bit offset, assembler rewrites.
ECE 232 L6.Assemb.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 6 MIPS Assembly.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
Assembly Code Example Selection Sort.
Systems Architecture Lecture 5: MIPS Instruction Set
CSE 340 Computer Architecture Spring 2014 MIPS ISA Review
MIPS Assembly Language Programming
Wannabe Lecturer Alexandre Joly inst.eecs.berkeley.edu/~cs61c-te
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Ch. 8 Functions.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 4 Assembly Language Programming 2.
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
CS3350B Computer Architecture Winter 2015 Lecture 4
Lecture 8: MIPS Instruction Set
 Procedures (subroutines) allow the programmer to structure programs making them : › easier to understand and debug and › allowing code to be reused.
Faculty of Computer Science © 2006 CMPUT 229 Pointers and Arrays Differentiating Pointers from Data.
Spring 2008, Jan. 14 ELEC / Lecture 2 1 ELEC / Computer Architecture and Design Spring 2007 Introduction Vishwani D. Agrawal.
The Structure of the CPU
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2006 Computer Organization and Architecture I Li-Yan Yuan.
1 Lecture 5: MIPS Examples Today’s topics:  the compilation process  full example – sort in C Reminder: 2 nd assignment will be posted later today.
Faculty of Computer Science © 2006 CMPUT 229 Why Computer Architecture? An Introduction to CMPUT 229.
Lecture 7: Instruction Set Architecture CSE 30: Computer Organization and Systems Programming Winter 2014 Diba Mirza Dept. of Computer Science and Engineering.
Computer Organization
Natawut NupairojAssembly Language1 Introduction to Assembly Programming.
Fall 2015, Aug 17 ELEC / Lecture 1 1 ELEC / Computer Architecture and Design Fall 2015 Introduction Vishwani D. Agrawal.
13/02/2009CA&O Lecture 04 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
Lecture 7. Instructions and High-Level to Machine Code Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education.
Spr 2015, Feb 9... ELEC / Lecture 4 1 ELEC / Computer Architecture and Design Spring 2015 Compiling and Executing Programs.
VAX. Agenda VAX and its History VAX ISA VAX Virtual Address Microcode.
Topic 2d High-Level languages and Systems Software
1 CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 4.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lec 4Systems Architecture1 Systems Architecture Lecture 4: Compilers, Assemblers, Linkers & Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
Computer Organization and Architecture I José Nelson Amaral
1 CS503: Operating Systems Spring 2014 Part 0: Program Structure Dongyan Xu Department of Computer Science Purdue University.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic5: Linking José Nelson Amaral.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 3.
Spring 2016, Jan 13 ELEC / Lecture 1 1 ELEC / Computer Architecture and Design Spring 2016 Introduction Vishwani D. Agrawal.
1 Lecture 6: Assembly Programs Today’s topics:  Large constants  The compilation process  A full example  Intro to the MARS simulator.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic4: Procedures José Nelson Amaral.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Lecture 3 Translation.
DDC 2223 SYSTEM SOFTWARE DDC2223 SYSTEM SOFTWARE.
Lecture 6: Assembly Programs
The University of Adelaide, School of Computer Science
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
May 2006 Saeid Nooshabadi ELEC2041 Microprocessors and Interfacing Lectures 24: Compiler, Assembler, Linker and Loader – I
Procedures (Functions)
Chapter 7 Subroutines Dr. A.P. Preethy
Assembly Programming using MIPS R3000 CPU
Topic 2e High-Level languages and Systems Software
CS170 Computer Organization and Architecture I
Instructions - Type and Format
Systems Architecture Lecture 5: MIPS Instruction Set
Jeremy R. Johnson Wed. Apr. 5, 2000
Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan
Systems Architecture I
Lecture 6: Assembly Programs
Assembly Programming using MIPS R3000 CPU
10/6: Lecture Topics C Brainteaser More on Procedure Call
ELEC / Computer Architecture and Design Fall 2014 Introduction
Computer Architecture and System Programming Laboratory
MIPS R3000 Subroutine Calls and Stack
Topic 2b ISA Support for High-Level Languages
Presentation transcript:

Faculty of Computer Science © 2006 CMPUT 229 Why Computer Architecture? An Introduction to CMPUT 229

© 2006 Department of Computing Science CMPUT 229 Organization of a Computer Clements, pp.20 COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 Structure of a Computer Clements, pp.21 COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 Stored-Program Computer Clements, pp.21 COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 A Personal-Computer (PC) Motherboard Clements, pp.22 COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 Below Your Program High-level language program in C void swap(int v[ ], int k) { int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } swap: muli$2, $5, 4 add$2, $4, $2 lw$15, 0($2) lw$16, 4($2) sw$16, 0($2) sw$15, 4($2) jr$31 Compiler Assembly language program (for MIPS) Assembler Binary machine language program (for MIPS) Hennessy-Patterson, pp.7

© 2006 Department of Computing Science CMPUT 229 Trying it out #include void swap(int v[ ], int k); void print_vector(int v[ ]); int main(int argc, char *argv[ ]) { int v[]={1,3,5,7,9,-1}; print_vector(v); swap(v,2); print_vector(v); } void swap(int v[], int k) { int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } void print_vector(int v[]) { int i; for(i=0 ; v[i]>0 ; i++) printf("\t%d ",v[i]); printf("\n"); }

swap: # vars= 8, regs= 2/0, args= 0, extra= 8.frame$fp,24,$31.mask0x ,-4.fmask0x ,0.setnoreorder.cpload$25.setreorder subu$sp,$sp,24.cprestore 0 sw$fp,20($sp) sw$28,16($sp) move$fp,$sp sw$4,24($fp) sw$5,28($fp) lw$2,28($fp) move$3,$2 sll$2,$3,2 lw$3,24($fp) addu$2,$2,$3 lw$3,0($2) sw$3,8($fp) lw$2,28($fp) move$3,$2 sll$2,$3,2 lw$3,24($fp) addu$2,$2,$3 lw$3,28($fp) move$4,$3 sll$3,$4,2 lw$4,24($fp) addu$3,$3,$4 addu$4,$3,4# page 1 $ gcc -S swap.c [on a MIPS R12K machine] lw$3,0($4) sw$3,0($2) lw$2,28($fp) move$3,$2 sll$2,$3,2 lw$3,24($fp) addu$2,$2,$3 addu$3,$2,4 lw$2,8($fp) sw$2,0($3)# page 2

swap: # vars= 0, regs= 0/0, args= 0, extra= 0.frame$sp,0,$31.mask0x ,0.fmask0x ,0.setnoreorder.cpload$25.setreorder sll$5,$5,2 addu$5,$5,$4 lw$2,4($5) lw$3,0($5) sw$2,0($5).setnoreorder.setnomacro j$31 sw$3,4($5).setmacro.setreorder.endswap.rdata.align2 $ gcc -O3 -S swap.c [on a MIPS R12K machine]

swap: link.w %a6,#-4 move.l 12(%a6),%d0 lsl.l #2,%d0 move.l 8(%a6),%a0 move.l (%a0,%d0.l),-4(%a6) move.l 12(%a6),%d0 move.l %d0,%d1 lsl.l #2,%d1 move.l 8(%a6),%a1 move.l 12(%a6),%d0 lsl.l #2,%d0 add.l 8(%a6),%d0 move.l %d0,%a0 addq.l #4,%a0 move.l (%a0),(%a1,%d1.l) move.l 12(%a6),%d0 lsl.l #2,%d0 add.l 8(%a6),%d0 move.l %d0,%a0 addq.l #4,%a0 move.l -4(%a6),(%a0) unlk %a6 rts $ gcc -S swap.c [for a 68K machine] swap: link.w %a6,#0 move.l 8(%a6),%a0 move.l 12(%a6),%d0 move.l (%a0,%d0.l*4),%d1 move.l 4(%a0,%d0.l*4),(%a0,%d0.l*4) move.l %d1,4(%a0,%d0.l*4) unlk %a6 rts $ gcc -O3 -S swap.c [for a 68K machine]

swap:.prologue 2, 2.vframe r2 mov r2 = r12 ;;.body st8 [r2] = r32 mov r14 = r2 ;; adds r14 = 8, r2 ;; st4 [r14] = r33 mov r14 = r2 adds r16 = 12, r2 ;; mov r14 = r2 ;; adds r14 = 8, r2 ;; ld4 r14 = [r14] ;; sxt4 r15 = r14 addl r14 = 4, r0 ;; setf.sig f6 = r15 setf.sig f7 = r14 ;; xma.l f6 = f6, f7, f0 ;; getf.sig r15 = f6 ld8 r14 = [r2] ;; add r14 = r15, r14 ;; ld4 r14 = [r14] ;; st4 [r16] = r14 mov r14 = r2 ;; adds r14 = 8, r2 ;; ld4 r14 = [r14] ;; sxt4 r15 = r14 addl r14 = 4, r0 ;; setf.sig f6 = r15 setf.sig f7 = r14 ;; xma.l f6 = f6, f7, f0 ;; getf.sig r15 = f6 ld8 r14 = [r2] ;; add r16 = r15, r14 mov r14 = r2 ;;#page 1 adds r14 = 8, r2 ;; $ gcc -S swap.c [on an Itanium I machine] ld4 r14 = [r14] ;; sxt4 r15 = r14 addl r14 = 4, r0 ;; setf.sig f6 = r15 setf.sig f7 = r14 ;; xma.l f6 = f6, f7, f0 ;; getf.sig r15 = f6 ld8 r14 = [r2] ;; add r14 = r15, r14 ;; adds r14 = 4, r14 ;; ld4 r14 = [r14] ;; st4 [r16] = r14 mov r14 = r2 ;; adds r14 = 8, r2 ;; ld4 r14 = [r14] ;; sxt4 r15 = r14 addl r14 = 4, r0 ;; setf.sig f6 = r15 setf.sig f7 = r14 ;; xma.l f6 = f6, f7, f0 ;; getf.sig r15 = f6 ld8 r14 = [r2] ;; add r14 = r15, r14 ;; adds r15 = 4, r14 mov r14 = r2 ;; adds r14 = 12, r2 ;; ld4 r14 = [r14] ;; st4 [r15] = r14.restore sp mov r12 = r2 br.ret.sptk.many b0.endp swap#.section.rodata.align 8# page 2

swap:.prologue.body sxt4 r33 = r33 ;; shladd r33 = r33, 2, r32 ;; mov r14 = r33 ;; ld4 r16 = [r14], 4 ;; ld4 r15 = [r14] ;; st4 [r33] = r15 st4 [r14] = r16 br.ret.sptk.many b0.endp swap# $ gcc -O3 -S swap.c [on an Itanium I machine]

© 2006 Department of Computing Science CMPUT 229 Machine Organization P-Pro bus (64-bit data, 36 bit address, 66 MHz) CPU Interrupt Controler 256-KB L2 Bus interface PCI Bridge PCI I/O Cards PCI I/O Cards PCI I/O Cards PCI Bus PCI Bridge PCI I/O Cards PCI I/O Cards PCI I/O Cards PCI Bus Memory Controller Memory Interleave Unit 1-, 2-, 4-way Interleaved DRAM CullerSinghGupta, pp. 32

© 2006 Department of Computing Science CMPUT 229 Example of SMP machine: Pentium “quad pack” P-Pro bus (64-bit data, 36 bit address, 66 MHz) CPU Interrupt Controler 256-KB L2 Bus interface CPU Interrupt Controler 256-KB L2 Bus interface CPU Interrupt Controler 256-KB L2 Bus interface CPU Interrupt Controler 256-KB L2 Bus interface PCI Bridge PCI I/O Cards PCI I/O Cards PCI I/O Cards PCI Bus PCI Bridge PCI I/O Cards PCI I/O Cards PCI I/O Cards PCI Bus Memory Controller Memory Interleave Unit 1-, 2-, 4-way Interleaved DRAM CullerSinghGupta, pp. 32

© 2006 Department of Computing Science CMPUT 229 Converting Source into Executable Files Henn-Pat, pp. A-4 COPYRIGHT 1998 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 A More Complete Story Source file Compiler Assembler file Object file Assembler Linker Source file Compiler Assembler file Object file Assembler Source file Compiler Assembler file Object file Assembler Program library Program library Executable file

© 2006 Department of Computing Science CMPUT 229 Converting Source into Executable Files Henn-Pat, pp. A-8 COPYRIGHT 1998 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 The Linker Henn-Pat, pp. A-18 COPYRIGHT 1998 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 When to use Assembly Language? –When you don’t have the tools to program in higher level: new embedded processors compilers that check deadlines for real time system do not exist yet –When the tools fail: Compilers still generate sub-optimal code –When you are building the tools: Compiler designer/builders must know assembly well

© 2006 Department of Computing Science CMPUT 229 Anatomy of an Object File Size and position of other pieces. Machine Code Binary Data Representation. References that must change if the program is moved in memory. Associate addresses with external label. Unresolved references. Compilation information to allow mapping of addresses to source code. Henn-Pat, pp. A-13 COPYRIGHT 1998 MORGAN KAUFMANN PUBLISHERS, INC. ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 Assembler Features  Data Layout Directives –string directives  Macros  Pseudo Instructions  Conditional Assembling Henn-Pat, pp. A-14/A-17