1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.

Slides:



Advertisements
Similar presentations
Registers of the 8086/ /2002 JNM.
Advertisements

Chapter 2 (cont.) An Introduction to the 80x86 Microprocessor Family Objectives: The different addressing modes and instruction types available The usefulness.
Introduction to Assembly Here we have a brief introduction to IBM PC Assembly Language –CISC instruction set –Special purpose register set –8 and 16 bit.
Lecture 6 Machine Code: How the CPU is programmed.
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
PC hardware and x86 3/3/08 Frans Kaashoek MIT
Assembly Language for Intel-Based Computers Chapter 2: IA-32 Processor Architecture Kip Irvine.
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.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
Gursharan Singh Tatla Block Diagram of Intel 8086 Gursharan Singh Tatla 19-Apr-17.
Unit-1 PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE Advance Processor.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
An Introduction to 8086 Microprocessor.
6.828: PC hardware and x86 Frans Kaashoek
1 Fundamental of Computer Suthida Chaichomchuen : SCC
Types of Registers (8086 Microprocessor Based)
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
The x86 Architecture Lecture 15 Fri, Mar 4, 2005.
Dr. José M. Reyes Álamo 1.  Review: ◦ of Comparisons ◦ of Set on Condition  Statement Labels  Unconditional Jumps  Conditional Jumps.
CET 3510 Microcomputer Systems Tech. Lecture 2 Professor: Dr. José M. Reyes Álamo.
1 ICS 51 Introductory Computer Organization Fall 2009.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
Assembly Language. Symbol Table Variables.DATA var DW 0 sum DD 0 array TIMES 10 DW 0 message DB ’ Welcome ’,0 char1 DB ? Symbol Table Name Offset var.
Chapter 2 Parts of a Computer System. 2.1 PC Hardware: Memory.
COMPUTER ORGANIZATION AND ASSEMBLY LANGUAGE Lecture 21 & 22 Processor Organization Register Organization Course Instructor: Engr. Aisha Danish.
Computers organization & Assembly Language Chapter 1 THE 80x86 MICROPROCESSOR.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
X86 Assembly Language We will be using the nasm assembler (other assemblers: MASM, as, gas)
3.4 Addressing modes Specify the operand to be used. To generate an address, a segment register is used also. Immediate addressing: the operand is a number.
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
Internal Programming Architecture or Model
Week 6 Dr. Muhammad Ayaz Intro. to Assembly Language.
Intel 8086 MICROPROCESSOR ARCHITECTURE
BITS Pilani Pilani Campus Pawan Sharma Lecture / ES C263 INSTR/CS/EEE F241 Microprocessor Programming and Interfacing.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
The Microprocessor & Its Architecture A Course in Microprocessor Electrical Engineering Department Universitas 17 Agustus 1945 Jakarta.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Precept 7: Introduction to IA-32 Assembly Language Programming
Chapter Overview General Concepts IA-32 Processor Architecture
Homework Reading Lab with your assigned section starts next week
Part of the Assembler Language Programmers Toolbox
Homework Reading Labs PAL, pp
8086 Microprocessor.
16.317: Microprocessor System Design I
Aaron Miller David Cohen Spring 2011
Basic Microprocessor Architecture
Assembly IA-32.
University of Gujrat Department of Computer Science
Homework Reading Continue work on mp1
Basic of Computer Organization
CS-401 Assembly Language Programming
Introduction to Assembly Language
BIC 10503: COMPUTER ARCHITECTURE
CS-401 Computer Architecture & Assembly Language Programming
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
Morgan Kaufmann Publishers Computer Organization and Assembly Language
CS 301 Fall 2002 Computer Organization
Fundamentals of Computer Organisation & Architecture
Homework Reading Machine Projects Labs PAL, pp
The Microprocessor & Its Architecture
Computer Architecture CST 250
CSC 497/583 Advanced Topics in Computer Security
Intel 8086.
Chapter 8: Instruction Set 8086 CPU Architecture
Computer Architecture and System Programming Laboratory
Part I Data Representation and 8086 Microprocessors
Presentation transcript:

1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006

2 Agenda Computer System Assembly Language (to help w/ lab) –Introduction of Assembly Language –Data types and registers –Instruction categories

3 Computer System

4 Storage Architecture Hard Disk Memory Registers Closer to CPU Faster Larger Space

5 REGISTERS A type of internal fast memory –Assume operations are on register operands –Very few in x86 - only 8! Need to know how to “address” them –For example, Add R1, R2 »means R1 = R1 + R2 All x86 computation instructions are of the form –Op Rx, Ry »Op indicates operation »Rx and Ry present operands Rx is destination operand Rx and Ry are source operands »For example: Add R1, R2 R1 = R1 + R2

/486/Pentium Registers IP

7 (E)AX, BX, CX, and DX are general purpose registers –AX is usually called accumulator register, or just accumulator. Most of arithmetical operations are done with AX. –BX is usually called base register. The common use is to do array operations. BX is usually used with other registers, most notably SP to point to stacks. –CX is commonly called counter register. This register is used for counter purposes. –DX register is the data register. It is usually used for keeping data value. CS, DS, ES, and SS are segment registers – You do not need to fiddle with these registers. SI and DI are index registers –Usually used to process arrays or strings. SI is called source index and DI is destination index. BP, SP, and IP are pointer registers –BP is base pointer. Used for preserving space to use local variables in C/C++ (the same as frame pointer?) Don’t need to fiddle with it. –SP is stack pointer. Points to the last used location in the stack. –IP is instruction pointer (it is the same as PC or program counter on other architectures). Points to the instruction that is going to be executed next. Cannot be directly modified.

8 Flag register Flag is a register that contains processor status –No direct access to it –C: carry flag (bit 0). Turns to 1 whenever the last arithmetical operation has carry or borrow, otherwise 0. –P: parity flag (bit 2). It is set to 1 if the last operation result has even number of 1’s. –A: auxiliary flag (bit 4). It is set in Binary Coded Decimal (BCD) operations. –Z: zero flag (bit 6). Is 1 if the last operation result is zero. –S: sign flag (bit 7). It is set to 1 if the most significant bit of the last operation is 1. –T: trap flag (bit 8). It is only used in debuggers to turn on the step-by-step feature. –I: interrupt flag (bit 9). Disables or enables interrupts. –D: direction flag (bit 10). If set, all string operations are done backward. –O: overflow flag (bit 11). If the bit is set, the last arithmetic operation resulted in overflow. –IOPL: I/O Privilege Level flag (bit 12 to 13). It is used to denote the privilege level of the running programs. –N: Nested Task flag (bit 14). Used to detect whether multiple tasks (or exceptions) occur. Most often used flags are O, D, I, S, Z, and C.

9 Assembly Language High level language –C, C++, Java language –Abstraction –Human friendly (e.g.) a = b + c; Assembly language –X86 Assembly language for Intel machine –Hard for human to read (e.g.) Mov eax, b Mov ebx, c Add eax, ebx Mov a, eax –High efficiency to use registers Machine language –Machine code for a specific machine –Machine readable (e.g.)

10 Assembly Language Programming Assembly Language –Processor-specific, low-level programming language »exposes most of processor features to the programmer –Describes »Data types and operations Size: Byte, Word, etc Meaning: integer, character »Storage Registers Memory »Specific instructions Will use Intel Assembly (x86, IA-32) –A small subset of all instructions

11 Generic Instructions Specify operation and operands Simple enough for hardware to execute directly For example: SUB R4, R3 –Operation is subtract –Operands are contents of memory locations called or addressed as R4, R3

12 Data Types - size Always take care of the type of data an instruction accesses!!!!

13 Operands The registers are operands of the instruction There are source and destination registers AND R7, R5 –R7 = R7 AND R5 »R7 is the destination operand (register) »R7 and R5 are source operands (registers)

14 X86 Examples Add EAX, EBX –Add the contents Is the same as earlier example: Add R1, R2 –here operands are in registers called R1 and R2 Intel uses the following names for 32b registers – EAX for R1, EBX for R2 – ECX for R3, EDX for R3 – The other four are registers called ESI, EDI, EBP, ESP Use only Intel register names in Assembly

15 Instruction Categories Data movement instructions Arithmetic operations Logical operations Comparison instructions Control Transfer Instructions –Unconditional –Conditional

16 Data Movement Instructions REGISTER, REGISTER1 and REGISTER2 can be any of the Intel registers (EAX, EBX, ECX, etc) Between registers mov REGISTER1, REGISTER2 To registers mov REGISTER, value mov REGISTER, variable To a variable mov variable, REGISTER From a variable mov REGISTER, variable

17 Simple Arithmetic Operations add REGISTER, VALUE –REGISTER = REGISTER + VALUE add REGISTER1, REGISTER2 –REGISTER1 = REGISTER1 + REGISTER2 – sub REGISTER, VALUE –REGISTER = REGISTER - VALUE sub REGISTER1, REGISTER2 –REGISTER1 = REGISTER1 - REGISTER2

18 Boolean Operation Instructions NOT AND OR XOR Example: OR EAX, EBX One way to set a register to 0 – XOR R1, R1 »(R1 AND (NOT R1) OR ((NOT R1) AND R1)

19 Comparison Instructions cmp REGISTER, VALUE cmp REGISTER1, REGISTER2 Sets special registers called flags –Each flag 1-bit storing 0 or 1 x86 has the following flag registers –N, Z, C, V Flags are used by the conditional jumps

20 Control Transfer Instructions Instructions execute sequentially, except for CTI Unconditional Transfer Instructions –e.g.) jmp Label Conditional Transfer Instructions –e.g.) jg Label Labels a_label:... CODE... another_label:...

21 Unconditional Transfer Instructions jmp LABEL

22 Conditional Transfer Instructions jg LABEL greater jge LABEL greater or equal jl LABEL less jle LABEL less or equal je LABEL equal jne LABEL not equal

23 Lab Assignments You will use assembly blocks inside C programs Visual Studio is the software tool we use in the lab

24 You will insert your code in the C program we give you int sum (int firstparam, int secondparam) { int retval; __asm { Your assembly code goes here } return retval; }

25 int sum (int firstparam, int secondparam) { int retval; __asm { mov eax, firstparam mov ebx, secondparam add eax, ebx mov retval, eax } return retval; }

26 Turning in Lab Assignments Start lab assignment ASAP Turnins past the deadline are automatically rejected