Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University. March 12, Xuan Guo

Size: px
Start display at page:

Download "Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University. March 12, Xuan Guo"

Transcription

1 CSC 3210 Computer Organization and Programming Georgia State University March 12, 2015 This lecture Plan for the lecture: Recap: Memory, The stack, The frame pointer Defining stack Variable Offsets Example gdb examine memory 1

2 Data types C Type SPARC Bits Unsigned Signed char byte 8 0, , 127 short half 16 0, 65,535-32,768, 32,767 int, long word 32 0, 4.294x x 10 9 All memory references must be aligned x byte quantities must begin in an address divisible by x Example int a, b; char c1; int c, d; //automatic variables int x, y, z; //use register for(z = 1; z < x+y;z++){ for(a = z; a>=z*y; a -= 10){ d = a + z; c1 = d * b; c = a + y/ z; } } 2

3 Memory Allocation and the Stack Automatic variables near top of memory = the Stack Stack has LIFO property Register %o6 holds the address of the last element placed on the stack = the stack pointer %sp More about the stack The stack grows downward to increase stack space, subtract from stack pointer sub %sp, 64, %sp 0x0000 The stack must be double word aligned %sp -> the stack Top of stack 0xf

4 Chopping Aligning the Stack The address in %sp must be divisible by 8 Clear lowest three bits by using the and operation Add a chopped negative # to increase size add add %sp, -94 & 0xfffffff8, %sp %sp, -94 & -8, %sp Results in 96 being subtracted from %sp 4

5 The Frame Pointer The value for %sp is not constant So it is difficult to reference a variable s location by using %sp The frame pointer, %fp = %i6, stores a copy of %sp before it is changed The save instruction performs addition and updates %fp Example using %fp Want to add 92 extra bytes and store five 4- byte variables %sp: save %sp, (-92 (5*4))) & -8, %sp 92 extra bytes a4: %fp-20: a3: %fp-16: a2: %fp-12: a1: %fp-8: a0: %fp-4: 5

6 Addressing Variables Load and Store operations are the only instructions that reference memory Both instructions take two operands One memory location, and one register Can access memory using different data types (byte, half word, word, double word) Load Instructions Mnemonic ldsb ldub ldsh lduh ld ldd Operation Load signed byte, propagate sign left in register Load unsigned byte, clear high 24 bits of register Load signed halfword, propogate sign left in register Load unsigned halfword, clear high 16 bits of register Load word Load double, reg. # even, first 4 bytes into reg. n, next 4 into reg. n + 1 6

7 Load Instruction Format ld [memory location], reg rd ld [%fp 4], %l1!a0 into %l1 ld [%fp 8], %l2!a1 into %l2 ld [%fp 16], %l4!a3 into %l4 Note: Memory location argument can be a register, register + immediate, or register + register Store Instructions Mnemonic stb sth st std Operation Store low byte of register, bits 0-7, into memory Store low two bytes of register, bits 0-15 into memory Store register Store double, reg. # even, first 4 bytes from reg. n, next 4 from reg. n + 1 st reg rs, [memory location] st %l1, [%fp 4]!%l1 into a0 7

8 Problems with Stack Variable Offsets Define the constants symbolically: define(a0_s, -4) ld [%fp + a0_s], %l1 define(a1_s, -8) ld [%fp + a1_s], %l2 define(a2_s, -12) ld [%fp + a2_s], %l3 but still have to compute the offsets a0_s = -4 a1_s = -8 a2_s = -12 a3_s = -16.global main main: save %sp, ( ) & -8, %sp ld [%fs + a0_s], %l1! evaluated by the assembler ld [%fs + a1_s], %l2 ld [%fs + a2_s], %l3 8

9 An Example Using Macros define(`local_var, `define(last_sym, 0) ) define(`var, `define(`last_sym, eval(last_sym-$2))$1 = last_sym ) local_var var(a0_s, 4)!a0_s = -4 var(a1_s, 4)!a1_s = -8.global main main: save %sp, (-92 + last_sym) & -8, %sp ld [%fp + a0_s], %l1 ld [%fp + a1_s], %l2 Data types C Type SPARC Bits Unsigned Signed char byte 8 0, , 127 short half 16 0, 65,535-32,768, 32,767 int, long word 32 0, 4.294x x 10 9 All memory references must be aligned x byte quantities must begin in an address divisible by x 9

10 But we still have problems local_var var(a_s, 4)!a_s = -4 var(b_s, 4)!b_s = -8 var(ch_s, 1)!ch_s = -9 var(c_s, 2)!c_s = -11 var(d_s, 4)!d_s = -15 ldsh [%fp + c_s], %o0! -11 ld [%fp + d_s], %o1! -15 Defining Stack Variable Offsets Define macros to compute the offsets and make the definitions define(local_var, `define(last_sym, 0) ') define(`var', `define(`last_sym', eval((last_sym - $2 & -$2)) $1 = last_sym') 10

11 Aligning Variables define(`var', `define(`last_sym', eval((last_sym - $2 & -$2)) $1 = last_sym') a_s = -4 b_s = -8 ch_s = -9 c_s = -12 d_s = -16 a_s = -4 b_s = -8 ch_s = -9 c_s = -11 d_s = -15 Aligning Variables %fp - 16 d a_s = -4 b_s = -8 ch_s = -9 c_s = -12 d_s = -16 %fp - 12 %fp - 9 %fp - 8 c ch b %fp - 4 a %fp 11

12 gdb examine memory the command x (for "examine") to examine memory in any of several formats independently of your program's data types. x/nfu addr n, the repeat count f, the display format `The default is `d' (decimal) initially `x' (hexadecimal) u, the unit size The unit size is any of b Bytes. h Halfwords (two bytes). w Words (four bytes). This is the initial default. g Giant words (eight bytes, double words). Example x/w $fp 4 x/b $fp - 5 Example int a; char ch; int b; int x, y; //memory //register x = 20; y = 30; a = x + y; b = x y; ch = a * b; 12

13 define(`local_var', `!local variables define(`last_sym', 0)') define(`var', `define(`last_sym', eval((last_sym - $2) & -$2)) $1 = last_sym') local_var var(a_s, 4) var(ch_s, 1) var(b_s, 4) define(x_r, l0) define(y_r, l1).global main main: save %sp, (-92 + last_sym) & -8, %sp mov 20, %x_r mov 30, %y_r add %x_r, %y_r, %o0 st %o0, [%fp + a_s] sub %x_r, %y_r, %o0 st %o0, [%fp + b_s] ld [%fp + a_s], %o0 ld [%fp + b_s], %o1 call.mul nop stb %o0, [%fp + ch_s] result: mov 1, %g1 ta 0 int a; char ch; int b; int x, y; x = 20; y = 30; a = x + y; b = x y; ch = a * b; 13

Xuan Guo. Lecture XIX: Subroutines (2) CSC 3210 Computer Organization and Programming Georgia State University. March 31, 2015.

Xuan Guo. Lecture XIX: Subroutines (2) CSC 3210 Computer Organization and Programming Georgia State University. March 31, 2015. CSC 3210 Computer Organization and Programming Georgia State University March 31, 2015 This lecture Plan for the lecture: Recap: Register Saving Subroutine Linkage call instruction jmpl instruction ret

More information

Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University. March 31, Lecture XX: Subroutines (3) Xuan Guo

Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University. March 31, Lecture XX: Subroutines (3) Xuan Guo CSC 3210 Computer Organization and Programming Georgia State University March 31, 2015 This lecture Plan for the lecture: Recap: Subroutine Linkage Arguments to subroutines More arguments to subroutines

More information

Lecture V: Register and SPARC Assembly Language Programming. Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University

Lecture V: Register and SPARC Assembly Language Programming. Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University Lecture V: Register and SPARC Assembly Language Programming CSC 3210 Computer Organization and Programming Georgia State University January 27, 2015 This lecture Plan for the lecture: Introduction Registers

More information

Lecture VII: The debugger gdb and Branching. Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University.

Lecture VII: The debugger gdb and Branching. Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University. Lecture VII: The debugger gdb and Branching CSC 3210 Computer Organization and Programming Georgia State University February 3, 2015 This lecture Plan for the lecture: Recap: Pipelining Filling delay slot

More information

CSE 30 Spring 2006 Final Exam

CSE 30 Spring 2006 Final Exam cs30x_ Student ID Name _ Signature CSE 30 Spring 2006 Final Exam 1. Number Systems _ (15 points) 2. Binary Addition/Condition Code Bits/Overflow Detection _ (12 points) 3. Branching _ (18 points) 4. Bit

More information

231 Spring Final Exam Name:

231 Spring Final Exam Name: 231 Spring 2010 -- Final Exam Name: No calculators. Matching. Indicate the letter of the best description. (1 pt. each) 1. address 2. object code 3. condition code 4. byte 5. ASCII 6. local variable 7..global

More information

CSE 30 Spring 2007 Final Exam

CSE 30 Spring 2007 Final Exam Login: cs30x Student ID Name Signature CSE 30 Spring 2007 Final Exam 1. Number Systems (25 points) 2. Binary Addition/Condition Code Bits/Overflow Detection (12 points) 3. Branching (19 points) 4. Bit

More information

CSE 30 Fall 2013 Final Exam

CSE 30 Fall 2013 Final Exam Login: cs30x Student ID Name Signature By filling in the above and signing my name, I confirm I will complete this exam with the utmost integrity and in accordance with the Policy on Integrity of Scholarship.

More information

CSE 30 Fall 2012 Final Exam

CSE 30 Fall 2012 Final Exam Login: cs30x Student ID Name Signature By filling in the above and signing my name, I confirm I will complete this exam with the utmost integrity and in accordance with the Policy on Integrity of Scholarship.

More information

CSE 30 Fall 2007 Final Exam

CSE 30 Fall 2007 Final Exam Login: cs30x Student ID Name Signature CSE 30 Fall 2007 Final Exam 1. Number Systems (25 points) 2. Binary Addition/Condition Code Bits/Overflow Detection (12 points) 3. Branching (19 points) 4. Bit Operations

More information

Lecture VIII: Branching and Control Statements. Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University.

Lecture VIII: Branching and Control Statements. Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University. Lecture VIII: Branching and Control Statements CSC 3210 Computer Organization and Programming Georgia State University February 5, 2015 This lecture Plan for the lecture: Recap: Filling delay slot Branching

More information

CSE 30 Winter 2014 Final Exam

CSE 30 Winter 2014 Final Exam Signature Login: cs30x Name Student ID By filling in the above and signing my name, I confirm I will complete this exam with the utmost integrity and in accordance with the Policy on Integrity of Scholarship.

More information

Lecture XXIV: Review Xuan Guo CSC 3210 Computer Organization and Programming Georgia State University April 23, 2015 Xuan Guo Lecture XXIV: Review

Lecture XXIV: Review Xuan Guo CSC 3210 Computer Organization and Programming Georgia State University April 23, 2015 Xuan Guo Lecture XXIV: Review CSC 3210 Computer Organization and Programming Georgia State University April 23, 2015 This lecture Review: set instruction register saving subroutine linkage arguments passing printf function instruction

More information

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls Announcements HW1 is due on this Friday (Sept 12 th ) Appendix A is very helpful to HW1. Check out system calls on Page A-48. Ask TA (Liquan chen: liquan@ece.rutgers.edu) about homework related questions.

More information

Chapter 5 Data Organization: The Load and Store Instructions

Chapter 5 Data Organization: The Load and Store Instructions Chapter 5 Data Organization: The Load and Store Instructions Arthur B. Maccabe Department of Computer Science The University of New Mexico Copyright 1993 2000, Arthur B. Maccabe and McGraw-Hill, Inc. Assembler

More information

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008 Math 230 Assembly Programming (AKA Computer Organization) Spring 2008 MIPS Intro II Lect 10 Feb 15, 2008 Adapted from slides developed for: Mary J. Irwin PSU CSE331 Dave Patterson s UCB CS152 M230 L10.1

More information

Lecture XXI: I/O (1) Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University. April 7, Xuan Guo. Lecture XXI: I/O (1)

Lecture XXI: I/O (1) Xuan Guo. CSC 3210 Computer Organization and Programming Georgia State University. April 7, Xuan Guo. Lecture XXI: I/O (1) CSC 3210 Computer Organization and Programming Georgia State University April 7, 2015 This lecture Plan for the lecture: External Data and Text printf function External Data and Text Two external variables

More information

231 Spring Final Exam Name:

231 Spring Final Exam Name: 231 Spring 2010 -- Final Exam Name: No calculators. Matching. Indicate the letter of the best description. (1 pt. each) 1. b address 2. d object code 3. g condition code 4. i byte 5. k ASCII 6. m local

More information

17. Instruction Sets: Characteristics and Functions

17. Instruction Sets: Characteristics and Functions 17. Instruction Sets: Characteristics and Functions Chapter 12 Spring 2016 CS430 - Computer Architecture 1 Introduction Section 12.1, 12.2, and 12.3 pp. 406-418 Computer Designer: Machine instruction set

More information

CSE 30 Fall 2006 Final Exam

CSE 30 Fall 2006 Final Exam cs30x_ Student ID Name _ Signature CSE 30 Fall 2006 Final Exam 1. Number Systems _ (15 points) 2. Binary Addition/Condition Code Bits/Overflow Detection _ (12 points) 3. Branching _ (20 points) 4. Bit

More information

Compiler Design. Homework 1. Due Date: Thursday, January 19, 2006, 2:00

Compiler Design. Homework 1. Due Date: Thursday, January 19, 2006, 2:00 Homework 1 Due Date: Thursday, January 19, 2006, 2:00 Your Name: Question 1 Is SPARC big- or little- Endian? When a word of data is stored in memory, which byte is stored in the first byte (i.e., in the

More information

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated CNIT 127: Exploit Development Ch 1: Before you begin Updated 1-14-16 Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend, such as Denial

More information

CSE 30 Winter 2009 Final Exam

CSE 30 Winter 2009 Final Exam Login: cs30x Student ID Name Signature CSE 30 Winter 2009 Final Exam 1. Number Systems / C Compiling Sequence (15 points) 2. Binary Addition/Condition Code Bits/Overflow Detection (12 points) 3. Branching

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

More information

Procedure Call. Procedure Call CS 217. Involves following actions

Procedure Call. Procedure Call CS 217. Involves following actions Procedure Call CS 217 Procedure Call Involves following actions pass arguments save a return address transfer control to callee transfer control back to caller return results int add(int a, int b) { return

More information

Final CSE 131 Fall 2014

Final CSE 131 Fall 2014 Login Name Student ID Name Signature Final CSE 131 Fall 2014 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 (35 points) (24 points) (30 points) (32 points) (25 points) (36 points) (30 points)

More information

EECE416 :Microcomputer Fundamentals and Design. X86 Assembly Programming Part 1. Dr. Charles Kim

EECE416 :Microcomputer Fundamentals and Design. X86 Assembly Programming Part 1. Dr. Charles Kim EECE416 :Microcomputer Fundamentals and Design X86 Assembly Programming Part 1 Dr. Charles Kim Department of Electrical and Computer Engineering Howard University www.mwftr.com 1 Multiple Address Access

More information

Expectations. Why learn Assembly Language? Administrative Issues. Assignments. CSC 3210 Computer Organization and Programming

Expectations. Why learn Assembly Language? Administrative Issues. Assignments. CSC 3210 Computer Organization and Programming CSC 3210 Computer Organization and Programming Introduction and Overview Dr. Anu Bourgeois (modified by Michael Weeks) Expectations Writing code with loops Base conversions Especially involving decimal

More information

Chapter 1. Computer Abstractions and Technology. Lesson 3: Understanding Performance

Chapter 1. Computer Abstractions and Technology. Lesson 3: Understanding Performance Chapter 1 Computer Abstractions and Technology Lesson 3: Understanding Performance Manufacturing ICs 1.7 Real Stuff: The AMD Opteron X4 Yield: proportion of working dies per wafer Chapter 1 Computer Abstractions

More information

Instruction Sets: Characteristics and Functions

Instruction Sets: Characteristics and Functions Instruction Sets: Characteristics and Functions Chapter 10 Lesson 15 Slide 1/22 Machine instruction set Computer designer: The machine instruction set provides the functional requirements for the CPU.

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 15: Midterm 1 Review Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Basics Midterm to cover Book Sections (inclusive) 1.1 1.5

More information

Mark II Aiken Relay Calculator

Mark II Aiken Relay Calculator Introduction to Embedded Microcomputer Systems Lecture 6.1 Mark II Aiken Relay Calculator 2.12. Tutorial 2. Arithmetic and logical operations format descriptions examples h 8-bit unsigned hexadecimal $00

More information

Orange Coast College. Business Division. Computer Science Department CS 116- Computer Architecture. The Instructions

Orange Coast College. Business Division. Computer Science Department CS 116- Computer Architecture. The Instructions Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture The Instructions 1 1 Topics: Assembly language, assemblers MIPS R2000 Assembly language Instruction set

More information

MIPS Functions and the Runtime Stack

MIPS Functions and the Runtime Stack MIPS Functions and the Runtime Stack COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

More information

Course Administration

Course Administration Fall 2017 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture 2/4 Avinash Kodi Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701 E-mail: kodi@ohio.edu

More information

CPSC 213. Introduction to Computer Systems. Procedures and the Stack. Unit 1e

CPSC 213. Introduction to Computer Systems. Procedures and the Stack. Unit 1e CPSC 213 Introduction to Computer Systems Unit 1e Procedures and the Stack 1 Readings for Next 3 Lectures Textbook Procedures - 3.7 Out-of-Bounds Memory References and Buffer Overflow - 3.12 2 Local Variables

More information

Chapter 2 SPARC Architecture Chinua Umoja

Chapter 2 SPARC Architecture Chinua Umoja Chapter 2 SPARC Architecture Chinua Umoja 1 SPARC is a load/store architecture Registers used for all arithmetic and logical operations 32 registers available at a time Uses only load and store instructions

More information

Communicating with People (2.8)

Communicating with People (2.8) Communicating with People (2.8) For communication Use characters and strings Characters 8-bit (one byte) data for ASCII lb $t0, 0($sp) ; load byte Load a byte from memory, placing it in the rightmost 8-bits

More information

Xuan Guo. Lecture XIV: Review of Chapter 3 & 4. CSC 3210 Computer Organization and Programming Georgia State University. March 5, 2015.

Xuan Guo. Lecture XIV: Review of Chapter 3 & 4. CSC 3210 Computer Organization and Programming Georgia State University. March 5, 2015. CSC 3210 Computer Organization and Programming Georgia State University March 5, 2015 This lecture Plan for the lecture: Binary Hardware Device Converting from Decimal to other number system Converting

More information

1. Introduction to Assembly Language

1. Introduction to Assembly Language www.vchowk.com 1. Introduction to Assembly Language Solved EXERCISE 1 Note: Dear fellows I tried my best to solve this exercise questions if there s any mistake or doubt in any question correct it and

More information

Reverse Engineering II: The Basics

Reverse Engineering II: The Basics Reverse Engineering II: The Basics Gergely Erdélyi Senior Manager, Anti-malware Research Protecting the irreplaceable f-secure.com Binary Numbers 1 0 1 1 - Nibble B 1 0 1 1 1 1 0 1 - Byte B D 1 0 1 1 1

More information

CS 270 Systems Programming. Debugging Tools. CS 270: Systems Programming. Instructor: Raphael Finkel

CS 270 Systems Programming. Debugging Tools. CS 270: Systems Programming. Instructor: Raphael Finkel Debugging Tools CS 270: Systems Programming Instructor: Raphael Finkel Gdb: The Gnu debugger It runs on most computers and operating systems. It allows you to examine a running executable program. It does

More information

Chapter Two MIPS Arithmetic

Chapter Two MIPS Arithmetic Chapter Two MIPS Arithmetic Computer Organization Review Binary Representation Used for all data and instructions Fixed size values: 8, 16, 32, 64 Hexadecimal Sign extension Base and virtual machines.

More information

Declaring Floating Point Data

Declaring Floating Point Data Declaring Floating Point Data There are three ways to declare floating point storage. These are E D L Single precision floating point, Double precision floating point, and Extended precision floating point.

More information

Computer Organization MIPS ISA

Computer Organization MIPS ISA CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE 232 MIPS ISA 1 (vonneumann) Processor Organization

More information

Reverse Engineering II: Basics. Gergely Erdélyi Senior Antivirus Researcher

Reverse Engineering II: Basics. Gergely Erdélyi Senior Antivirus Researcher Reverse Engineering II: Basics Gergely Erdélyi Senior Antivirus Researcher Agenda Very basics Intel x86 crash course Basics of C Binary Numbers Binary Numbers 1 Binary Numbers 1 0 1 1 Binary Numbers 1

More information

CS241 Computer Organization Spring 2015 IA

CS241 Computer Organization Spring 2015 IA CS241 Computer Organization Spring 2015 IA-32 2-10 2015 Outline! Review HW#3 and Quiz#1! More on Assembly (IA32) move instruction (mov) memory address computation arithmetic & logic instructions (add,

More information

CPSC 213. Introduction to Computer Systems. Static Scalars and Arrays. Unit 1b

CPSC 213. Introduction to Computer Systems. Static Scalars and Arrays. Unit 1b CPSC 213 Introduction to Computer Systems Unit 1b Static Scalars and Arrays 1 Reading for Next 3 Lectures Companion 2.4.1-2.4.3 Textbook Array Allocation and Access 3.8 2 The Big Picture Build machine

More information

EN164: Design of Computing Systems Lecture 09: Processor / ISA 2

EN164: Design of Computing Systems Lecture 09: Processor / ISA 2 EN164: Design of Computing Systems Lecture 09: Processor / ISA 2 Professor Sherief Reda http://scale.engin.brown.edu Electrical Sciences and Computer Engineering School of Engineering Brown University

More information

Assembly level Programming. 198:211 Computer Architecture. (recall) Von Neumann Architecture. Simplified hardware view. Lecture 10 Fall 2012

Assembly level Programming. 198:211 Computer Architecture. (recall) Von Neumann Architecture. Simplified hardware view. Lecture 10 Fall 2012 19:211 Computer Architecture Lecture 10 Fall 20 Topics:Chapter 3 Assembly Language 3.2 Register Transfer 3. ALU 3.5 Assembly level Programming We are now familiar with high level programming languages

More information

Under the Hood: Data Representation. Computer Science 104 Lecture 2

Under the Hood: Data Representation. Computer Science 104 Lecture 2 Under the Hood: Data Representation Computer Science 104 Lecture 2 Admin Piazza, Sakai Up Everyone should have access Homework 1 Posted Due Feb 6 PDF or Plain Text Only: No Word or RTF Recommended: Learn

More information

Systems Architecture I

Systems Architecture I Systems Architecture I Topics Assemblers, Linkers, and Loaders * Alternative Instruction Sets ** *This lecture was derived from material in the text (sec. 3.8-3.9). **This lecture was derived from material

More information

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers Outline of Introduction Administrivia What is computer architecture? What do computers do? Representing high level things in binary Data objects: integers, decimals, characters, etc. Memory locations (We

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 4: Logic Operations and Introduction to Conditionals Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Overview Previously examined

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize two

More information

CSE 220: System Fundamentals I Unit 14: MIPS Assembly: Multi-dimensional Arrays. Kevin McDonnell Stony Brook University CSE 220

CSE 220: System Fundamentals I Unit 14: MIPS Assembly: Multi-dimensional Arrays. Kevin McDonnell Stony Brook University CSE 220 CSE 220: System Fundamentals I Unit 14: MIPS Assembly: Multi-dimensional Arrays 1 Memory Alignment Perhaps at some point in your MIPS assembly programming you tried to perform a lw and received an error

More information

Instruction encoding. MIPS Instruction encoding

Instruction encoding. MIPS Instruction encoding Instruction encoding The ISA defines The format of an instruction (syntax) The meaning of the instruction (semantics) Format = Encoding Each instruction format has various fields Opcode field gives the

More information

Computer Processors. Part 2. Components of a Processor. Execution Unit The ALU. Execution Unit. The Brains of the Box. Processors. Execution Unit (EU)

Computer Processors. Part 2. Components of a Processor. Execution Unit The ALU. Execution Unit. The Brains of the Box. Processors. Execution Unit (EU) Part 2 Computer Processors Processors The Brains of the Box Computer Processors Components of a Processor The Central Processing Unit (CPU) is the most complex part of a computer In fact, it is the computer

More information

Chapter 2: Instructions:

Chapter 2: Instructions: Chapter 2: Instructions: Language of the Computer Computer Architecture CS-3511-2 1 Instructions: To command a computer s hardware you must speak it s language The computer s language is called instruction

More information

MIPS Assembly Language Programming

MIPS Assembly Language Programming MIPS Assembly Language Programming COE 308 Computer Architecture Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline Assembly

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

More information

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3 A Processor Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University See: P&H Chapter 2.16-20, 4.1-3 Let s build a MIPS CPU but using Harvard architecture Basic Computer System Registers ALU

More information

CPSC 213. Introduction to Computer Systems. Procedures and the Stack. Unit 1e

CPSC 213. Introduction to Computer Systems. Procedures and the Stack. Unit 1e CPSC 213 Introduction to Computer Systems Unit 1e Procedures and the Stack Readings for Next 3 Lectures Textbook Procedures - 3.7 Out-of-Bounds Memory References and Buffer Overflow - 3.12 Local Variables

More information

F28HS2 Hardware-Software Interfaces. Lecture 6: ARM Assembly Language 1

F28HS2 Hardware-Software Interfaces. Lecture 6: ARM Assembly Language 1 F28HS2 Hardware-Software Interfaces Lecture 6: ARM Assembly Language 1 CISC & RISC CISC: complex instruction set computer original CPUs very simple poorly suited to evolving high level languages extended

More information

Processor. Han Wang CS3410, Spring 2012 Computer Science Cornell University. See P&H Chapter , 4.1 4

Processor. Han Wang CS3410, Spring 2012 Computer Science Cornell University. See P&H Chapter , 4.1 4 Processor Han Wang CS3410, Spring 2012 Computer Science Cornell University See P&H Chapter 2.16 20, 4.1 4 Announcements Project 1 Available Design Document due in one week. Final Design due in three weeks.

More information

Assembler. Lecture 8 CS301

Assembler. Lecture 8 CS301 Assembler Lecture 8 CS301 Discussion Given the following function header, int foo(int a, int b); what will be on the stack before any of the calculations in foo are performed? Assume foo() calls some other

More information

MIPS Assembly Language Programming

MIPS Assembly Language Programming MIPS Assembly Language Programming ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals [Adapted

More information

CNIT 127: Exploit Development. Ch 2: Stack Overflows in Linux

CNIT 127: Exploit Development. Ch 2: Stack Overflows in Linux CNIT 127: Exploit Development Ch 2: Stack Overflows in Linux Stack-based Buffer Overflows Most popular and best understood exploitation method Aleph One's "Smashing the Stack for Fun and Profit" (1996)

More information

Description of the Simulator

Description of the Simulator Description of the Simulator The simulator includes a small sub-set of the full instruction set normally found with this style of processor. It includes advanced instructions such as CALL, RET, INT and

More information

Cache Organizations for Multi-cores

Cache Organizations for Multi-cores Lecture 26: Recap Announcements: Assgn 9 (and earlier assignments) will be ready for pick-up from the CS front office later this week Office hours: all day next Tuesday Final exam: Wednesday 13 th, 7:50-10am,

More information

3. Instruction Set Architecture The MIPS architecture

3. Instruction Set Architecture The MIPS architecture 3. Instruction Set Architecture The MIPS architecture EECS 370 Introduction to Computer Organization Winter 2007 Prof. Valeria Bertacco & Prof. Scott Mahlke EECS Department University of Michigan in Ann

More information

The PAW Architecture Reference Manual

The PAW Architecture Reference Manual The PAW Architecture Reference Manual by Hansen Zhang For COS375/ELE375 Princeton University Last Update: 20 September 2015! 1. Introduction The PAW architecture is a simple architecture designed to be

More information

Representation of Information

Representation of Information Representation of Information CS61, Lecture 2 Prof. Stephen Chong September 6, 2011 Announcements Assignment 1 released Posted on http://cs61.seas.harvard.edu/ Due one week from today, Tuesday 13 Sept

More information

Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize

More information

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1 CSIS1120A 10. Instruction Set & Addressing Mode CSIS1120A 10. Instruction Set & Addressing Mode 1 Elements of a Machine Instruction Operation Code specifies the operation to be performed, e.g. ADD, SUB

More information

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction

More information

CENG3420 Lecture 03 Review

CENG3420 Lecture 03 Review CENG3420 Lecture 03 Review Bei Yu byu@cse.cuhk.edu.hk 2017 Spring 1 / 38 CISC vs. RISC Complex Instruction Set Computer (CISC) Lots of instructions of variable size, very memory optimal, typically less

More information

A Processor! Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

A Processor! Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3 A Processor! Hakim Weatherspoon CS 3410, Spring 2010 Computer Science Cornell University See: P&H Chapter 2.16-20, 4.1-3 Announcements! HW2 available later today HW2 due in one week and a half Work alone

More information

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 10 Instruction Sets: Characteristics and Functions

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 10 Instruction Sets: Characteristics and Functions William Stallings Computer Organization and Architecture 8 th Edition Chapter 10 Instruction Sets: Characteristics and Functions Instruction Set = The complete collection of instructions that are recognized

More information

Basic Assembly SYSC-3006

Basic Assembly SYSC-3006 Basic Assembly Program Development Problem: convert ideas into executing program (binary image in memory) Program Development Process: tools to provide people-friendly way to do it. Tool chain: 1. Programming

More information

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS The Microprocessor without Interlocked Pipeline Stages

More information

Computer Architecture 1 ح 303

Computer Architecture 1 ح 303 Lecture 4 A. Addressing MODES 1. Introduction to assembly language programming: Program is a sequence of commands used to tell a microcomputer what to do. Each command in a program is an instruction Programs

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 4

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 4 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 4 LAST TIME Enhanced our processor design in several ways Added branching support Allows programs where work is proportional to the input values

More information

Homework 2. Lecture 6: Machine Code. Instruction Formats for HW2. Two parts: How to do Homework 2!!!!

Homework 2. Lecture 6: Machine Code. Instruction Formats for HW2. Two parts: How to do Homework 2!!!! Lecture 6: Machine How to do Homework 2!!!! Homework 2 Two parts: Part 1: Use Debug to enter and run a simple machine code program convert input data into 2 s complement hex enter data at the correct address

More information

Chapter 2. lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1

Chapter 2. lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1 Chapter 2 1 MIPS Instructions Instruction Meaning add $s1,$s2,$s3 $s1 = $s2 + $s3 sub $s1,$s2,$s3 $s1 = $s2 $s3 addi $s1,$s2,4 $s1 = $s2 + 4 ori $s1,$s2,4 $s2 = $s2 4 lw $s1,100($s2) $s1 = Memory[$s2+100]

More information

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015 Branch Addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant or address 6 bits 5 bits 5 bits 16 bits PC-relative

More information

Experiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program.

Experiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program. Experiment 3 Introduction: In this experiment the students are exposed to the structure of an assembly language program and the definition of data variables and constants. Objectives: Assembly language

More information

Course Administration

Course Administration Fall 2018 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture Introduction 4/4 Avinash Karanth Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701

More information

Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21

Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21 2.9 Communication with People: Byte Data & Constants Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21 32: space 33:! 34: 35: #...

More information

Machine and Assembly Language Principles

Machine and Assembly Language Principles Machine and Assembly Language Principles Assembly language instruction is synonymous with a machine instruction. Therefore, need to understand machine instructions and on what they operate - the architecture.

More information

CPS311 - COMPUTER ORGANIZATION. A bit of history

CPS311 - COMPUTER ORGANIZATION. A bit of history CPS311 - COMPUTER ORGANIZATION A Brief Introduction to the MIPS Architecture A bit of history The MIPS architecture grows out of an early 1980's research project at Stanford University. In 1984, MIPS computer

More information

Tutorial 1: C-Language

Tutorial 1: C-Language Tutorial 1: C-Language Problem 1: Data Type What are the ranges of the following data types? int 32 bits 2 31..2 31-1 OR -2147483648..2147483647 (0..4294967295 if unsiged) in some machines int is same

More information

Lecture 4: MIPS Instruction Set

Lecture 4: MIPS Instruction Set Lecture 4: MIPS Instruction Set No class on Tuesday Today s topic: MIPS instructions Code examples 1 Instruction Set Understanding the language of the hardware is key to understanding the hardware/software

More information

Programming the ARM. Computer Design 2002, Lecture 4. Robert Mullins

Programming the ARM. Computer Design 2002, Lecture 4. Robert Mullins Programming the ARM Computer Design 2002, Lecture 4 Robert Mullins 2 Quick Recap The Control Flow Model Ordered list of instructions, fetch/execute, PC Instruction Set Architectures Types of internal storage

More information

CPSC 213, Winter 2009, Term 2 Midterm Exam Date: March 12, 2010; Instructor: Mike Feeley

CPSC 213, Winter 2009, Term 2 Midterm Exam Date: March 12, 2010; Instructor: Mike Feeley CPSC 213, Winter 2009, Term 2 Midterm Exam Date: March 12, 2010; Instructor: Mike Feeley This is a closed book exam. No notes. Electronic calculators are permitted. Answer in the space provided. Show your

More information

Part 7. Stacks. Stack. Stack. Examples of Stacks. Stack Operation: Push. Piles of Data. The Stack

Part 7. Stacks. Stack. Stack. Examples of Stacks. Stack Operation: Push. Piles of Data. The Stack Part 7 Stacks The Stack Piles of Data Stack Stack A stack is an abstract data structure that stores objects Based on the concept of a stack of items like a stack of dishes Data can only be added to or

More information

CS401 - Computer Architecture and Assembly Language Programming Glossary By

CS401 - Computer Architecture and Assembly Language Programming Glossary By CS401 - Computer Architecture and Assembly Language Programming Glossary By absolute address : A virtual (not physical) address within the process address space that is computed as an absolute number.

More information

Computer Architecture and System Software Lecture 06: Assembly Language Programming

Computer Architecture and System Software Lecture 06: Assembly Language Programming Computer Architecture and System Software Lecture 06: Assembly Language Programming Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Assignment 3 due thursday Midterm

More information

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI. CSCI 402: Computer Architectures Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI Recall Big endian, little endian Memory alignment Unsigned

More information

SPARC Architecture. SPARC Registers

SPARC Architecture. SPARC Registers SPRC rchitecture 8-bit cell (byte) is smallest addressable unit 32-bit addresses, i.e., 32-bit virtual address space Larger sizes: at address 7 0 byte 15 +1 halfword 31 +1 +2 +3 word +1 +2 +3 +4 +5 +6

More information