CS-401 Computer Architecture & Assembly Language Programming

Slides:



Advertisements
Similar presentations
Jump Condition.
Advertisements

Hindu College, Amritsar.
Flow of Control Instruction/Control structure Looping structure Looping structure Branching structure Branching structure For assembly language program.
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 4: The 80x86 Instruction Set Architecture Registers-Instructions Constantine D. Polychronopoulos.
Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 5 MIXING C AND ASSEMBLY.
Department of Computer Science and Software Engineering
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
Gursharan Singh Tatla 21-Nov-20101www.eazynotes.com.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Assembly Language for Intel-Based Computers
CS2422 Assembly Language & System Programming October 17, 2006.
Flow Control Instructions
Practical Session 1 Computer Architecture and Assembly Language.
Conditional Processing Computer Organization & Assembly Language Programming Dr Adnan Gutub aagutub ‘at’ uqu.edu.sa [Adapted from slides of Dr. Kip Irvine:
Lecture 3 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Lecture 5 Multiplication, Division and Branches Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
(Flow Control Instructions)
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 5 Branching and Looping.
LEA instruction The LEA instruction can be used to get the offset address of a variable Example ORG 100h MOV AL, VAR1 ; check value of VAR1 by moving it.
Conditional Loop Instructions, Conditional Structures
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.
Practical Session 2. Flags Register (Status Register) A flag is a single bit of information whose meaning is independent from any other bit Each flag.
COMP 2003: Assembly Language and Digital Logic Chapter 2: Flags and Instructions Notes by Neil Dickson.
Assembly 06. Outline cmp (review) Jump commands test mnemonic bt mnemonic Addressing 1.
Jumps, Loops and Branching. Unconditional Jumps Transfer the control flow of the program to a specified instruction, other than the next instruction in.
Assembly Language Wei Gao. Assembler language Instructions.
Selection and Iteration Chapter 8 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
K.K. Leung Fall 2008Introductory Pentium Programming1 Pentium Architecture: Introductory Programming Kin K. Leung
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Practical Session 2 Computer Architecture and Assembly Language.
Computer Architecture and Assembly Language
CSC 221 Computer Organization and Assembly Language
Computer Architecture and Assembly Language
Practical Session 2.
CSC 221 Computer Organization and Assembly Language
Today we are going to discuss about,
Instruksi Set Prosesor 8088
ADDRESSING MODES.
EE3541 Introduction to Microprocessors
Morgan Kaufmann Publishers Computer Organization and Assembly Language
INSTRUCTION SET.
Assembly IA-32.
INSTRUCTION SET.
More on logical instruction and
Assembly Language Programming Part 2
ADDRESSING MODES.
Microprocessor and Assembly Language
Processor Processor characterized by register set (state variables)
Calculator in assembly language
اصول اساسی برنامه نویسی به زبان اسمبلی
CS 301 Fall 2002 Assembly Instructions
فصل پنجم انشعاب و حلقه.
8086 Registers Module M14.2 Sections 9.2, 10.1.
CS-401 Computer Architecture & Assembly Language Programming
Flow Control Instructions
CNET 315 Microprocessor & Assembly Language
Computer Architecture and System Programming Laboratory
X86 Assembly Review.
Chapter 7 –Program Logic and Control
Carnegie Mellon Ithaca College
CS-401 Computer Architecture and Assembly Language Programming
Chapter 8: Instruction Set 8086 CPU Architecture
Computer Architecture and Assembly Language
Computer Architecture and System Programming Laboratory
UNIT-II ADDRESSING MODES & Instruction set
CS-401 Computer Architecture & Assembly Language Programming
Presentation transcript:

CS-401 Computer Architecture & Assembly Language Programming Lecture-8 Addressing Modes Branching

In the Last Lecture We discussed memory addresses

Addressing Modes Offset Addressing ; Default segment = ds mov ax, [0x1234] ; word move mov ah, [0x1234] ; byte move mov byte[0x1234], 10 mov word[0x1234], 10

Addressing Modes Base Addressing ; Default segment = ds mov ax, [bx] mov byte [bx], 10 mov word [bx], 10 ; Default segment = ss mov ax, [bp] mov byte [bp], 10 mov word [bp], 10

Addressing Modes Index Addressing ; Default segment = ds mov ax, [si] mov byte [di], 10 mov word [si], 10

Base + Offset Addressing Addressing Modes Base + Offset Addressing ; Default segment = ds mov ax, [bx+0x0100] mov byte [bx+0x100], 10 mov word [bx+0x100], 10 ; Default segment = ss mov byte [bp+0x10], 10 mov word [bp+0x100], 10

Index + Offset Addressing Addressing Modes Index + Offset Addressing ; Default segment = ds mov ax, [si+0x0100] mov byte [di+0x100], 10 mov word [di+0x100], 10 mov byte [si+0x10], 10 mov word [si+0x0100], 10

Base + Index Addressing Addressing Modes Base + Index Addressing ; Default segment = ds mov ax, [bx+si] mov byte [bx+si], 10 mov word [bx+di], 10 ; Default segment = ss mov byte [bp+si], 10 mov word [bp+di], 10

Base + Index + Offset Addressing Addressing Modes Base + Index + Offset Addressing ; Default segment = ds mov ax, [bx+si+0x0100] mov byte [bx+si+0x0100], 10 mov word [bx+di+0x0100], 10 ; Default segment = ss mov byte [bp+si+0x0100], 10 mov word [bp+di+0x0100], 10

Addressing Modes General Form [base + index + offset]

Illegal Addressing Example mov al, [bl] ; Address cannot be 8-bit ; has to be 16-bit

Illegal addressing

Illegal Addressing Example mov ax, [bx-si] ; Registers cannot be ; subtracted

Illegal Addressing Example mov ax, [bx+bp] ; Two bases cannot be ; used in one addressing

Illegal Addressing Example mov ax, [si+di] ; Two indices cannot be ; used in one addressing

Physical Address Calculation [cs:bx+si+0x0700] BX = 0x0100 SI = 0x0200 CS = 0x1000 Effective Address = EA = Base + Index + Offset EA = 0x0100 + 0x0200 + 0x0700 = 0x0A00 Physical Address = Segment*0x10+EA = 0x1000*0x10+0xA00 = 0x10A00

Physical Address Calculation [bx+0x7000] BX = 0x9100 DS = 0x1500 Effective Address = EA = Base + Index + Offset = 0x9100 + 0x0000 + 0x07000 = 0x10100 ; 17-bits ! = 0x0100 ; Segment wrap ; around

Physical Address Calculation [bx+0x7000] BX = 0x9100 DS = 0x1500 Effective Address = EA = 0x0100 ; Segment wrap ; around Physical Address = Segment*0x10+EA = 0x1500*0x10+0x100 = 0x15100

Physical Address Calculation [bx+0x0100] BX = 0x0100 DS = 0xFFF0 Effective Address = EA = Base + Index + Offset = 0x0100 + 0x0000 + 0x0100 = 0x0200 Physical Address = Segment*0x10+EA = 0xFFF0*0x10+0x0200 = 0x100100 ; 21-bits ! = 0x00100 ; memory wrap ; around

CMP Subtracts the source (src) from destination (dest) Does not change contents of src or dest. Affects AF,CF,OF,PF,SF and ZF. The relation is of destination to source.

Conditional Jumps jz ;jump if zero [ZF=1] Jnz ;jump if not zero [ZF=0] Example cmp ax, bx jz label1

Conditional Jumps je ;jump if equal [same as jz] Jne ;jump if not equal [same as jnz]

Conditional Jumps jc ;jump if carry [CF=1] Jnc ;jump if not carry [CF=0] Example add ax, bx jc label1 sub ax, bx jnc label1

Conditional Jumps ja ;jump if above [ZF = 0 and CF=0] jb ;jump if below [CF=1] unsigned integers jl ;jump if less [SF <> OF=0] jg ;jump if greater [ZF = 0 and SF=OF] signed integers

Conditional Jumps jae ;jump if above or equal jbe ;jump if below or equal jge ;jump if greater or equal jle ;jump if less or equal jno ;Jump if not overflow jns ; Jump if not sign

Renamed Conditional Jumps JNBE  JA JNB  JAE JNAE  JB JNA  JBE JZ  JE JNLE  JG JNL  JGE JNGE  JL JNG  JLE JNZ  JNE JPO  JNP JPE  JP

Conditional Jumps jcxz ;jump if the cx register is zero [cx=0]