CS2422 Assembly Language & System Programming September 19, 2006.

Slides:



Advertisements
Similar presentations
CH10 Instruction Sets: Characteristics and Functions
Advertisements

1 Lecture 3: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 2 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Microprocessors General Features To be Examined For Each Chip Jan 24 th, 2002.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
Outline Learning Assembly by an Example.  Program Formats  Some Simple Instructions  Assemble and Execute Learning Another Example  Data Definition.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Assembly Language for Intel-Based Computers Chapter 2: IA-32 Processor Architecture Kip Irvine.
Microprocessors Introduction to ia32 Architecture Jan 31st, 2002.
Real instruction set architectures
What is an instruction set?
ICS312 Set 3 Pentium Registers. Intel 8086 Family of Microprocessors All of the Intel chips from the 8086 to the latest pentium, have similar architectures.
August 26 TA: Angela Van Osdol Questions?. What is a computer? Tape drives? Big box with lots of lights? Display with huge letters? Little box with no.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Assembly Language for Intel-Based Computers, 5th Edition
Basic Microcomputer Design. Inside the CPU Registers – storage locations Control Unit (CU) – coordinates the sequencing of steps involved in executing.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
1 Fundamental of Computer Suthida Chaichomchuen : SCC
Fall 2012 Chapter 2: x86 Processor Architecture. Irvine, Kip R. Assembly Language for x86 Processors 6/e, Chapter Overview General Concepts IA-32.
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Assembly Language A Brief Introduction. Unit Learning Goals CPU architecture. Basic Assembler Commands High level Programming  Assembler  Machine Language.
Computer Architecture and Organization
1 ICS 51 Introductory Computer Organization Fall 2009.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Computer Architecture EKT 422
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
August 27 Books? ? Accounts?. What does a computer look like? Tape drives? Big box with lots of lights? Display with huge letters? Little box with.
Computers organization & Assembly Language Chapter 1 THE 80x86 MICROPROCESSOR.
What is a program? A sequence of steps
University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Instruction Sets. Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can.
MODULE 5 INTEL TODAY WE ARE GOING TO DISCUSS ABOUT, FEATURES OF 8086 LOGICAL PIN DIAGRAM INTERNAL ARCHITECTURE REGISTERS AND FLAGS OPERATING MODES.
Microprocessor Fundamentals Week 2 Mount Druitt College of TAFE Dept. Electrical Engineering 2008.
Internal Programming Architecture or Model
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 2: IA-32 Processor Architecture (c) Pearson Education, All rights reserved. You.
Preliminary to Assembly Language Programming CE 140 A1/A2 28 June 2003.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Chapter Overview General Concepts IA-32 Processor Architecture
Computers’ Basic Organization
Assembly language.
A Closer Look at Instruction Set Architectures
Computer Organization & Assembly Language Chapter 3
Assembly Language for Intel-Based Computers, 5th Edition
University of Gujrat Department of Computer Science
Homework Reading Continue work on mp1
Symbolic Instruction and Addressing
Introduction to Assembly Language
University of Gujrat Department of Computer Science
8086 Registers Module M14.2 Sections 9.2, 10.1.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
CS 301 Fall 2002 Computer Organization
Symbolic Instruction and Addressing
August 29 New address for Fang-Yi
Assembly Language (CSW 353)
Lecture 06 Programming language.
Computer Architecture CST 250
Introduction to Microprocessor Programming
Unit-I 80386DX Architecture
Chapter 6 –Symbolic Instruction and Addressing
January 16 The books are here. Assignment 1 now due Thursday 18 Jan.
Part I Data Representation and 8086 Microprocessors
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

CS2422 Assembly Language & System Programming September 19, 2006

Today’s Topics (1/2) How the CPU executes a program. Where we can store the data. –Registers –Memory –Constants

Today’s Topics (2/2) Data representation – What are stored in the main memory? –Binary, Decimal, Hexadecimal…etc. –Units: Byte, Word, Double-word…etc. –Memory Addresses. –Characters Strings. –Big or Little Endian.

Study Guide Textbook: Sections 1.3, 2.1 (except ), 2.2, 2.3. Read (in depth): –2.1.1 and –2.2.1 and –2.3.1 and Browse the rest (like reading news stories).

Program Loading & Execution A simpler view: –clock synchronizes CPU operations –control unit (CU) coordinates sequence of execution steps –ALU performs arithmetic and bitwise processing

Instruction Execution Cycle Fetch Decode Fetch operands Execute Store output

Clock Not the wall clock. Ever wondering what the CPU clock rate (like 2.0GHz) means? Next slide: using the memory read as an example

Figure 2.7 (from Textbook)

Cache Memory High-speed expensive static RAM both inside and outside the CPU. –Level-1 cache: inside the CPU –Level-2 cache: outside the CPU Cache hit: when data to be read is already in cache memory Cache miss: when data to be read is not in cache memory.

How a Program Runs

Multitasking OS can run multiple programs at the same time. Multiple threads of execution within the same program. Scheduler utility assigns a given amount of CPU time to each running program. Rapid switching of tasks –gives illusion that all programs are running at once –the processor must support task switching.

Data Representations Consider this simple view: The whole program is stored in main memory. –Including program instructions (code) and data. –CPU loads the instructions and data from memory for execution. – Don’t worry about the disk for now.

Where are the Data? Registers (inside the CPU) Memory Constant

Registers General-Purpose: –AX, BX, CX, DX: 16 bits –Splitted into H and L parts, 8 bits each. –Extended into E?X to become 32-bit register (i.e., EAX, EBX,…etc.).

Convention AX: accumulator BX: base register CX: count register DX: data register Some instructions use them implicitly. (e.g., LOOP uses CX with no mentioning.)

Other Registers We will explain their meaning when we encounter them later this semester: Segment (CS, DS, SS, ES) Pointer (IP, SP, BP) Index (SI, DI) Flags

Memory Organized like mailboxes, numbered 0, 1, 2, 3,…, 2 n -1. –Each box can hold 8 bits (1 byte) –So it is called byte-addressing. …

Byte? Word? The number has limited range. 1 Byte = 8 Bits: –Binary: to –Hexadecimal: 00 to FF –Decimal: 0 to 255 Word = 2 or 4 bytes, depending on the machine. In 80x86, it means 2 bytes.

Number Systems I assume that now you all know: –Binary & hexadecimal numbers. –Conversion between them and decimal. –How to represent negative numbers (in 2’s compliment).

Memory Address Byte Addressing: each memory location has 8 bits. If we have only 16 bytes… –4 bits are enough for an address What if we have 64K? 1M? 1G? …

Memory Address 16-bit address is enough for up to 64K 20-bit for 1M 32-bit for 4G Most servers need more than 4G!! That’s why we need 64-bit CPUs like Alpha (DEC/Compaq/HP) or Merced (Intel).

Confused Now? So, is the memory 8-bit or 32-bit? It depends on what you ask: –Content or Address? –Remember addresses can be stored in memory as well. (They are called pointers in PASCAL and C.)

Break

Character String So how are strings like “Hello, World!” are stored in memory? ASCII Code! (or Unicode…etc.) Each character is stored as a byte. Review: how is “1234” stored in memory?

Integer A byte can hold an integer number: –between 0 and 255 (unsigned) or –between –128 and 127 (2’s compliment) How to store a bigger number? Review: how is 1234 stored in memory?

Big or Little Endian? Example: 1234 is stored in 2 bytes. = in binary = 04 D2 in hexadecimal Do you store 04 or D2 first? Big Endian: 04 first. Little Endian: D2 first.  Intel’s choice

Reason for Little-Endian? –More consistent for variable length (e.g., 2 bytes, 4 bytes, 8 bytes…etc.)

Writing the First Program… MOV AX, var1 MOV BX, 1 ADD AX, BX MOV var1, AX

Constant (or Immediate) Data Compare: –MOV AX, 25 –MOV AX, var1 ; assume var1 at address 25 The constant 25 in the first case is called immediate data. The second case may be considered as: –MOV AX, [25]

Food for Thought Example: MOV AX, 25 But, where is the number stored? In memory? A related question: where is the instruction (MOV AX, 25) stored? What do we do if we want to move the data in memory address 25 to AX?

Multi-Stage Pipeline Pipelining makes it possible for processor to execute instructions in parallel Instruction execution divided into discrete stages Example of a non- pipelined processor. Many wasted cycles.

Pipelined Execution More efficient use of cycles, greater throughput of instructions: For k states and n instructions, the number of required cycles is: k + (n – 1)

Instruction Set Architecture... the attributes of a [computing] system as seen by the programmer, i.e. the conceptual structure and functional behavior, as distinct from the organization of the data flows and controls, the logic design, and the physical implementation. – Amdahl, Blaaw, and Brooks, 1964 i nterface between hardware and low-level software standardizes instructions, machine language bit patterns, etc. advantage: different implementations of the same architecture disadvantage: sometimes prevents using new innovations

RISC vs. CISC RISC: PowerPC, MIPS, DEC Alpha CISC: x86/Pentium, AMD, VAX Example: x86 (CISC): MOV AX, a ADD AX, b RISC: Load R1, a Load R2, b Add R2, R1