Systems Architecture I

Slides:



Advertisements
Similar presentations
Henk Corporaal TUEindhoven 2011
Advertisements

The University of Adelaide, School of Computer Science
Lecture 9: MIPS Instruction Set
Instructor: Tor Aamodt
UEE072HM Linking HLL and ALP An example on ARM. Embedded and Real-Time Systems We will mainly look at embedded systems –Systems which have the computer.
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
Exploring Security Vulnerabilities by Exploiting Buffer Overflow using the MIPS ISA Andrew T. Phillips Jack S. E. Tan Department of Computer Science University.
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
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.
Computer Architecture CSCE 350
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.
Apr. 12, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 6: Branching and Procedures in MIPS* Jeremy R. Johnson Wed. Apr. 12, 2000.
Faculty of Computer Science © 2006 CMPUT 229 Why Computer Architecture? An Introduction to CMPUT 229.
Lecture 8: MIPS Instruction Set
Lec 9Systems Architecture1 Systems Architecture Lecture 9: Assemblers, Linkers, and Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Assemblers, Linkers, and Loaders See: P&H Appendix B.3-4.
Assemblers, Linkers, and Loaders See: P&H Appendix B.3-4 Kevin Walsh CS 3410, Spring 2011 Computer Science Cornell University.
Assemblers, Linkers, and Loaders See: P&H Appendix B.3-4 Kevin Walsh CS 3410, Spring 2011 Computer Science Cornell University.
CS 61C L19 Running a Program aka Compiling, Assembling, Loading, Linking (CALL) II (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia
MIPS Assembler Programming
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.
RISC Concepts, MIPS ISA and the Mini–MIPS project
CS 61C L14Introduction to MIPS: Instruction Representation II (1) Garcia, Spring 2004 © UCB Roy Wang inst.eecs.berkeley.edu/~cs61c-tf inst.eecs.berkeley.edu/~cs61c.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University See: P&H Appendix A1-2, A.3-4 and 2.12.
Topic 2d High-Level languages and Systems Software
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lecture # 1 SPIM & MIPS Programming. SPIM SPIM is a MIPS32 simulator that reads and executes assembly language program written for SPIM. Platform -Unix,
Lec 4Systems Architecture1 Systems Architecture Lecture 4: Compilers, Assemblers, Linkers & Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
12/8/2015\course\cpeg323-07Fs\Topic2b-323.ppt1 Topic 2b High-Level languages and System Software (Languages) Introduction to Computer Systems Engineering.
1 Lecture 6: Assembly Programs Today’s topics:  Large constants  The compilation process  A full example  Intro to the MARS simulator.
1 간단한 C 프로그램 김희자, 최정욱. 2 목차 예제 소스 코드 컴파일 어셈블리 언어 Dlite 디버거 수행.
CS 61C: Great Ideas in Computer Architecture CALL continued ( Linking and Loading) 1 Instructors: Nicholas Weaver & Vladimir Stojanovic
Assemblers, Linkers, and Loaders Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See: P&H Appendix B.3-4 and 2.12.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
KYC - Know your compiler Introduction to GCC
Makefiles CSSE 332 Operating Systems
Lecture 3 Translation.
Simple Scalar 설치 및 사용법 일반대학원 전산학과 강서일 (2003 ) 손재락 ( )
Lecture 6: Assembly Programs
MIPS ISA-II: Procedure Calls & Program Assembly
Memory Layout for Process
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Instructor: Justin Hsia
Topic 2e High-Level languages and Systems Software
There is one handout today at the front and back of the room!
Assemblers, Linkers, and Loaders
Assemblers, Linkers, and Loaders
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
Green Subscription Based PC Announced
Assembler Directives Example program: .data # DATA segment city: .asciiz “Seattle” .align 2 num: .word 2210, 2341, 26, 0x022ec,
Henk Corporaal TUEindhoven 2010
Jeremy R. Johnson Wed. Apr. 5, 2000
Memory Layout for Process
Computer Organization and Design Assembly & Compilation
Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan
Lecture 6: Assembly Programs
Systems Architecture I
Assemblers, Linkers, and Loaders
10/6: Lecture Topics C Brainteaser More on Procedure Call
Compilers Jakub Yaghob
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
Memory Layout for Process
Program Assembly.
Assemblers, Linkers, and Loaders
Topic 2b ISA Support for High-Level Languages
Presentation transcript:

Systems Architecture I Systems Architecture I (CS 281-001) Lecture 4: Compilers, Assemblers, Linkers & Loaders Jeremy R. Johnson April 4, 2001 April 4, 2001 Systems Architecture I

Systems Architecture I September 4, 1997 Introduction Objective: To introduce the role of compilers, assemblers, linkers and loaders. To see what is underneath a C program: assembly language, machine language, and executable. April 4, 2001 Systems Architecture I

Systems Architecture I September 4, 1997 Below Your Program Example from a Unix system Source Files: count.c and main.c Corresponding assembly code: count.s and main.s Corresponding machine code (object code): count.o and main.o Library functions: libc.a Executable file: a.out format for a.out and object code: ELF (Executable and Linking Format) April 4, 2001 Systems Architecture I

Producing an Executable Program September 4, 1997 Producing an Executable Program Example from a Unix system (SGI Challenge running IRIX 6.5) Compiler: count.c and main.c  count.s and main.s gcc -S count.c main.c Assembler: count.s and main.s  count.o and main.o gcc -c count.s main.s as count.s -o count.o Linker/Loader: count.o main.o libc.a  a.out gcc main.o count.o ld main.o count.o -lc (additional libraries are required) April 4, 2001 Systems Architecture I

Systems Architecture I September 4, 1997 Source Files void main() { int n,s; printf("Enter upper limit: "); scanf("%d",&n); s = count(n); printf("Sum of i from 1 to %d = %d\n",n,s); } int count(int n) { int i,s; s = 0; for (i=1;i<=n;i++) s = s + i; return s; } April 4, 2001 Systems Architecture I

Assembly Code for MIPS (count.s) September 4, 1997 Assembly Code for MIPS (count.s) #.file 1 "count.c" .option pic2 .section .text .text .align 2 .globl count .ent count count: .LFB1: .frame $fp,48,$31 # vars= 16, regs= 2/0, args= 0, extra= 1 6 .mask 0x50000000,-8 .fmask 0x00000000,0 subu $sp,$sp,48 .LCFI0: sd $fp,40($sp) April 4, 2001 Systems Architecture I

Systems Architecture I September 4, 1997 .LCFI1: sd $28,32($sp) .LCFI2: move $fp,$sp .LCFI3: .set noat lui $1,%hi(%neg(%gp_rel(count))) addiu $1,$1,%lo(%neg(%gp_rel(count))) daddu $gp,$1,$25 .set at sw $4,16($fp) sw $0,24($fp) li $2,1 # 0x1 sw $2,20($fp) .L3: lw $2,20($fp) lw $3,16($fp) slt $2,$3,$2 beq $2,$0,.L6 b .L4 L6: lw $2,24($fp) lw $3,20($fp) addu $2,$2,$3 sw $2,24($fp) .L5: lw $2,20($fp) addu $3,$2,1 sw $3,20($fp) b .L3 .L4: lw $3,24($fp) move $2,$3 b .L2 .L2: move $sp,$fp ld $fp,40($sp) ld $28,32($sp) addu $sp,$sp,48 j $31 .LFE1: .end count April 4, 2001 Systems Architecture I

Executable Program for MIPS (a.out) September 4, 1997 Executable Program for MIPS (a.out) 0000000 7f45 4c46 0102 0100 0000 0000 0000 0000 0000020 0002 0008 0000 0001 1000 1060 0000 0034 0000040 0000 6c94 2000 0024 0034 0020 0007 0028 0000060 0023 0022 0000 0006 0000 0034 1000 0034 0000100 1000 0034 0000 00e0 0000 00e0 0000 0004 0000120 0000 0004 0000 0003 0000 0114 1000 0114 0000140 1000 0114 0000 0015 0000 0015 0000 0004 0000160 0000 0001 7000 0002 0000 0130 1000 0130 0000200 1000 0130 0000 0080 0000 0080 0000 0004 0000220 0000 0008 7000 0000 0000 01b0 1000 01b0 0000240 1000 01b0 0000 0018 0000 0018 0000 0004 0000260 0000 0004 0000 0002 0000 01c8 1000 01c8 0000300 1000 01c8 0000 0108 0000 0108 0000 0004 0000320 0000 0004 0000 0001 0000 0000 1000 0000 0000340 1000 0000 0000 3000 0000 3000 0000 0005 • • • • • • • • • • • • • • • • • • • • • April 4, 2001 Systems Architecture I