CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola 68000.

Slides:



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

There are two types of addressing schemes:
Assembly Programming Notes for Practical2 Munaf Sheikh
C Programming and Assembly Language Janakiraman V – NITK Surathkal 2 nd August 2014.
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.
Princess Sumaya University
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
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.
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.
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
An Introduction to 8086 Microprocessor.
1 Fundamental of Computer Suthida Chaichomchuen : SCC
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR1 Addressing Mode.
Low Level Programming Lecturer: Duncan Smeed Overview of IA-32 Part 1.
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.
Faculty of Engineering, Electrical Department,
The x86 Architecture Lecture 15 Fri, Mar 4, 2005.
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
1 ICS 51 Introductory Computer Organization Fall 2009.
26-Nov-15 (1) CSC Computer Organization Lecture 6: Pentium IA-32.
9/20/6Lecture 2 - Prog Model Architecture, Data Types and Addressing Modes.
CNIT 127: Exploit Development Ch 1: Before you begin.
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.
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
Computers organization & Assembly Language Chapter 1 THE 80x86 MICROPROCESSOR.
ECE291 Computer Engineering II Lecture 3 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
Review of Assembly language. Recalling main concepts.
X86 Assembly Language We will be using the nasm assembler (other assemblers: MASM, as, gas)
MOV Instruction MOV destination,source  MOV AX,BX  MOV SUM,EAX  MOV EDX,ARRAY[EBX][ESI]  MOV CL,5  MOV DL,[BX]
MODULE 5 INTEL TODAY WE ARE GOING TO DISCUSS ABOUT, FEATURES OF 8086 LOGICAL PIN DIAGRAM INTERNAL ARCHITECTURE REGISTERS AND FLAGS OPERATING MODES.
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Stack Operations Dr. Hadi AL Saadi.
Instruction set Architecture
Format of Assembly language
Assembly Lab 3.
Data Transfers, Addressing, and Arithmetic
Part of the Assembler Language Programmers Toolbox
Chapter 4 Data Movement Instructions
Basic Microprocessor Architecture
Assembly IA-32.
ADDRESSING MODES.
University of Gujrat Department of Computer Science
Introduction to Assembly Language
BIC 10503: COMPUTER ARCHITECTURE
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
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
68000 Architecture, Data Types and Addressing Modes
The Microprocessor & Its Architecture
Symbolic Instruction and Addressing
Computer Architecture CST 250
X86 Assembly Review.
CSC 497/583 Advanced Topics in Computer Security
Chapter 8: Instruction Set 8086 CPU Architecture
Introduction to Assembly
Computer Architecture and System Programming Laboratory
Presentation transcript:

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola 68000

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 2 Major Differences Addressing: –Motorola: 24-bit addressing –Intel: 32-bit addressing Memory Access: –Motorola: Big-endian Memory Access –Intel: Little-endian memory access Instruction Format: –Motorola: mnemonic source, dest –Intel: mnemonic dest, source Registers –Motorola: 16 registers (8 address, 8 data) –Intel: 8 registers (some with special purpose) Stack –Motorola: Entries can be words or double words –Intel: Entries are all double words

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 3 Registers 4 32-bit data registers –EAX, EBX, ECX, EDX 4 32-bit index registers –EPB, ESP, ESI, EDI 6 16-bit segment registers –CS, DS, SS, ES, FS, GS 1 32-bit EIP 1 32-bit EFLAGS

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 4 Data Registers EAX/R0 (accumulator) – for arithmetic operations EBX/R3 (base) – holds address of a procedure or variable; also for arithmetic operations and data movement. ECX/R1 (counter) – for repeating or looping instructions EDX/R2 (data) – for I/O; for multiply and divide operations Can be used as general purpose registers. The low order byte of EAX can be accessed by AL, the next higher order byte can be accessed by AH, and the entire low order word can be accessed by AX.

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 5 Index Registers ESP/R4 (stack pointer) – offset from the top of the stack EBP/R5 (base pointer) – base for the stack (frame pointer) ESI/R6 (source index) – for string movement. Address of source string is in ESI. EDI/R7 (dest index) – for string movement. The destination address is in EDI. Can be used as general purpose registers (except R4, R5) Can access first (rightmost) word with SP, BP, SI, DI, respectively.

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 6 Segment Registers CS (code segment) – base location of executable instructions DS (data segment) – default location for variables SS (stack segment) – base location for the stack ES, FS, GS (extra segment) – additional base location for memory variables

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 7 EIP and EFLAGS Registers Motorola Program Counter (PC) –EIP – Extended (32-bit) Instruction Pointer Motorola Status Register (SR) –EFLAGS – Extended Flags SF – sign ZF – zero OF – overflow CF – carry IF – interrupt (can interrupts occur) TF – trap (same as Motorola trace bit)

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 8 Constants and Expressions Decimal (default) –Motorola: 123 –Intel: 123 Binary – trailing ‘b’ –Motorola: %1010 –Intel: 1010b Hexadecimal – trailing ‘h’ (and must start with number) –Motorola: $AF01 –Intel: 0AF01h Octal – trailing ‘o’ or ‘q’ –Intel: 123o or 123q Strings –‘hello’ or “hello”

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 9 Directives and Comments Motorola EQU –EQU – assigns a name to a string or numeric constant Motorola DC –DB – define byte (8 bits) –DW – define word (2 bytes) –DD – define double word (4 bytes / 2 words) Motorola DS –Use DB, DW, or DD with ? for value Intel Only –Equal-sign – symbolic constant ‘;’ indicate comments, as in Motorola

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 10 Directives and Comments Define starting places for code and data. –.code –.data –.stack 4096 – reserve 4096 bytes for the stack

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 11 Directives: Example Motorola ; Data and Constants CHAR1DC.B ‘A’ CHAR2 DC.B +127 CHAR3 DS.B 1 LIST DS.B 10, 20, 30 Intel.data CHAR1 DB ‘A’ CHAR2 DB +127 CHAR3 DB ? LIST DB 10, 20, 30

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 12 Instruction Format Mnemonic dest,source –ADD Motorola: ADD source, dest Intel: ADD dest, source RTL: dest <- dest + source –MOVE Motorola: MOVE source, dest Intel: MOV dest, source RTL: dest <- source General Rules –Source can be memory, register or constant –Destination can be memory or non-segment register –Only one of source and destination can be memory –Source and destination must be same size

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 13 Addressing Modes Motorola Immediate Mode –Intel Immediate mode –Operand = Value Motorola Absolute Long Mode –Intel Direct mode – 32 bit address –Operand = Location Motorola Address/Data Register Direct –Intel Register mode –Operand = Reg Motorola Register Indirect –Intel Register Indirect –Operand = [Reg] Motorola Indexed Basic Mode –Intel Base with Displacement mode –Operand = [Reg + Displacement] Motorola Autoincrement/Autodecrement –No equivalent in Intel

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 14 Flow Control Compare –Motorola: CMP –Intel: CMP Branch Always –Motorola: BRA –Intel: JMP Branch Greater/Less Than –Motorola: BGT/BLT –Intel: JG/JL Branch Greater/Less Than or Equal To –Motorola: BGE/BLE –Intel: JGE/JLE As in Motorola, branching instructions (Jump) branch to a displacement added to the program counter (instruction pointer IP)

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 15 Example: Summing an Array INTEL IA-32 Assembly Language LEA EBX, ARRAY; Initialize base (EBX) register with ARRAY MOV ECX, N; Initialize counter (ECX) register with N MOV EAX, 0; Clear accumulator (EAX) MOV EDI, 0; Clear index (EDI) LOOP:ADD EAX, [EBX + EDI *4]; Add next number into accumulator (EAX) INC EDI; Increment index register (EDI) DEC ECX; Decrement counter register (ECX) JG LOOP; Branch if [ECX > 0] MOV SUM, EAX; Store sum (EAX) in memory (SUM) MOTOROLA Assembly Language MOVE.L N, D1; Initialize counter (D1) MOVEA.L #ARRAY, A2; Initialize base (A2) with ARRAY CLR.L D0; Clear accumulator (D0) LOOPADD.W (A2)+, D0; Add next number into accumulator, increment A2 SUBQ.L #1, D1; Decrement counter register (D1) BGT LOOP; Branch if [D1 > 0] MOVE.L D0, SUM; Store sum (D0) in memory (SUM)

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 16 The Stack All entries in the stack are double words (4 bytes) Pushing an item onto the stack –Motorola: MOVE itemSrc, -(SP) –Intel: PUSH itemSrc Popping an item from the stack –Motorola: MOVE +(SP), itemDest –Intel: POP itemDest PUSH and POP implicitly use ESP for current stack pointer

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 17 Subroutines Calling a Subroutine –Motorola: BSR/JSR sub –Intel: CALL sub Return from Subroutine –Motorola: RTS –Intel: RET Storing Multiple Registers on the stack –Motorola: MMOVE D3-D5/A2, -(SP) –Intel: PUSHAD

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 18 Subroutines Example INTEL IA-32 Assembly Language PUSH OFFSET ARRAY; Push address of ARRAY onto stack PUSH N; Push number of elements onto stack CALL LADD; Branch to subroutine LADD (list add) ADD ESP,4; Clean stack POP SUM; Store returned sum in memory (SUM) LADD:PUSHAD MOV EDI, 0; Clear index (EDI) MOV EAX, 0; Clear accumulator (EAX) MOV EBX,[ESP+44]; Load ARRAY address into EBX MOV ECX,[ESP+40]; Load N into ECX LOOP:ADD EAX, [EBX + EDI *4]; Add next number into accumulator (EAX) INC EDI; Increment index register (EDI) DEC ECX; Decrement counter register (ECX) JG LOOP; Branch if [ECX > 0] MOV [ESP+44],EAX; Overwrite ARRAY in stack with sum POPAD RET

CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 19 References HVZ: Chapter 3.16 – 3.24 HVZ: Appendix D Art of Assembly - Usenet: comp.lang.asm.x86