Memory Address Segment-offset address Base location (segment) + logical location (offset) Example: For 32-bits segment-offset address, 08F1:0100 represents.

Slides:



Advertisements
Similar presentations
Introduction to 8086 Microprocessor
Advertisements

1 Assembly Instructions Assembly language instructions may involve mnemonics, labels, variables, constants, and directives. Examples are as follows. here.
Assembly Language Fundamentals
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.
8086 Assembly Language Programming I
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
The 8086 Assembly Programming Data Allocation & Addressing Modes
Princess Sumaya University
1 Lecture 4: Data Transfer, Addressing, and Arithmetic Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Irvine: Assembly Language for Intel-Based Computers (1999) Symbolic Constants Equal-sign Directive EQU Directive TEXTEQU Directive.
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 Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages.
1 Lecture 3: Assembly Language Fundamentals Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Assembly Language for Intel-Based Computers Chapter 3: Assembly Language Fundamentals Kip Irvine.
Assembly Language Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages.
Irvine, Kip R. Assembly Language For Intel-Based Computers.data string db "This is a string." COUNT = ($–string) ; calculate string length.code mov cx,COUNT.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
Fundamentals of Assembly language
ICS312 Set 4 Program Structure. Outline for a SMALL Model Program Note the quiz at the next lecture will be to reproduce this slide.MODEL SMALL.586 ;
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
An Introduction to 8086 Microprocessor.
1/2002JNM1 Basic Elements of Assembly Language Integer Constants –If no radix is given, the integer is assumed to be decimal. Int 21h  Int 21 –A hexadecimal.
Chapter 3 Elements of Assembly Language. 3.1 Assembly Language Statements.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Introduction to 8086 Assembly Language Assembly Language Programming University of Akron Dr. Tim Margush.
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Faculty of Engineering, Electrical Department,
The x86 PC Assembly Language, Design, and Interfacing By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey © 2010, 2003, 2000, 1998 Pearson.
Overview of Assembly Language Chapter 4 S. Dandamudi.
Chapter Five–80x86 Assembly program development Principles of Microcomputers 2015年11月15日 2015年11月15日 2015年11月15日 2015年11月15日 2015年11月15日 2015年11月15日 1.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Click to add Title Comunicación y Gerencia Click To add Subtitle Click to add Text Fundamentals of Assembly Language.
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.
Assembly Language programming
In Class Program Write, assemble and test a program: –Use the DB directive to define the following list of numbers and name it array: 31h, 32h, 33h, 34h.
Microprocessors used in Personal Computers. The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt.
Review of Assembly language. Recalling main concepts.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Assembly Language Lecture 2. Lecture Outline Program Structure Memory models Data Segment Stack Segment Code Segment Input and Output Instructions INT.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
1 Using the Assembler Chapter – 4(A). 2 Exchanging Two Variables title Exchange Two Variables (Exchange.asm).model small.stack 100h.data value1 db 0Ah.
Assembly language programming
Instruction set Architecture
Format of Assembly language
Assembly Lab 3.
Data Transfers, Addressing, and Arithmetic
Assembly Language programming
Microprocessor Systems Design I
Microprocessor and Assembly Language
Microprocessor and Assembly Language
Assembly IA-32.
Computer Organization & Assembly Language
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
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.
8086 Registers Module M14.2 Sections 9.2, 10.1.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
Symbolic Instruction and Addressing
Assembler Directives end label end of program, label is entry point
Computer Architecture and System Programming Laboratory
Chapter 6 –Symbolic Instruction and Addressing
Chapter 8: Instruction Set 8086 CPU Architecture
Introduction to 8086 Assembly Language
Presentation transcript:

Memory Address Segment-offset address Base location (segment) + logical location (offset) Example: For 32-bits segment-offset address, 08F1:0100 represents a 20-bits absolute address F 1 (0)

Floating-Point Unit 80-bit Registers ST(0) ST(1) ST(7) FPU Instruction Pointer FPU Data Pointer Tag Register Control Register Status Register 48-bit Pointer Register 16-bit Control Register Opcode Register

DUP Operator db 20 dup(0) ; 20 bytes, all equal to zero db 20 dup (?) ; 20 un-initialized bytes db 4 dup(“ABC”) ; 12 bytes: “ABCABCABCABC” db 4096 dup(0);

Assembly Language Basic elements 1. Constant and expression E+07

Integer Constants 26 decimal 1Ah hexadecimal 1101b binary 36q octal 2BH hexadecimal 43Q octal 36D decimal 48d decimal

Constant Expression, Symbolic constants and Character or String Constants Constant expression *20 -3*4/ E+04 A symbolic constant rows = 5 columns = 10 Number = rows * columns Character or string constant ‘ABC’ ‘X’ “ This is a test” “The dog is black”

Assembly Language Statement Consists of : 1. A name, an instruction mnemonic, operands, and a comment. It has the following form: [name] [mnemonic] [operands] [;comment] Example: call sub1 ; transfer of control

Names A name identifies a label, variable, symbolic, or a keyword. What can be used as a name: 1. A… Z a… z ? 4. _ Underscore 6. $ Length limit----maximum of 247 characters (in MASM)

Variables and Labels 1. A variable is a location in a program’s data area that has been assigned a name. Such as: count1 db 50 ; message db “ Hello world!”, odh, 0ah 2. Label. If a name appears in the code area of a program, it is called a label. Example: LabelA: mov ax, 0 mov bx, ffh

Hello World Program title Hello World Program (hello.asm) ; This program displays "Hello, world!".model small.stack 100h.data message db "Hello, world!",0dh,0ah,'$'.code main proc mov mov ds,ax mov ah,9 mov dx,offset message int 21h mov ax,4C00h int 21h main endp end main

Analyze the Program.model small ----specify the program’s memory model For that model we can have: Tiny--- code + data less than 64k Samll--- code <=64k, data,<=64k One code segment and one data segment Medium---Data <=64k, code any size. Multiple code segment, one data segment Compact---Code <= 64k, data any size. Multiple data segment, one code segment Large---Code >64k, data >64k both multiple segment Huge---Same as the large model, except that individual variables such as arrays may be large than 64k Flat--- No segments. 32-bits addresses are used for both code and data. ***Protected mode only

Standard Assembler Directives end---end of program assembly endp--- end of procedure page---Set a page format for the listing file proc---Begin procedure title---Title of the listing file.code--- Mark the beginning of the code segment.data---.model---.stack---Set the size of the stack segment

Data Allocation Directives DB byte DW DD DF, DP define far pointer DQ define Quadword DT define 10 bytes

Examples Char1 db ‘A’ ; ASCII char. Char2 db “A’ –10 ; expression Smallest db –128 Max_unsign db 255 Myval db ? Only reserve memory, no initializeers List db 10,20,30,40,50

Characters and Integers are one and the same Char db ‘A’ Hex db 41h Dec db 65 Bin db Oct db 101q

Type mix is allowed List db 10, 20, 41h, b List2 db 0ah, 29h, ‘a’, 22

Strings Cstring db “Good morning”,0 Pstring db 12, “Good morning” Longstring db “This is a long string, that” db “ clearly is going to take” db “ several lines to store”,0

Symbolic Constants Equate directives They allow constants and literals to be given symbolic names. 1. Equal-Sign Directive (redefinable) The syntax is: name = expression Examples: string = ‘XY’ count = 500 minInt = 8000h

To assign a 32 bits integer is required.386 maxLong = 7FFFFFFFh ; maximum 32-bit signed value minLong = h ; Minimum 32-bit signed value “=“ defined symbols can be redefined any number of times.

Example of Using Directives count =5 mov al, count mov dl, al count =10 mov cx, count count = 2000 mov ax, count

EQU and TEXTEQU directives EQU is not redefinable TEXTEQU is redefinable Examples: maxint equ 32767; Numeric float1 equ ; String TEXTEQU syntax: name TEXREQU name TEXTEQU textmacro

Intel chip Instructions 1. MOV---Data transfer instruction Instruction format: MOV reg, reg MOV reg, immed MOV mem, reg MOV mem, immed MOV reg, mem MOV mem16, segreg MOV reg16, segreg MOV segreg, immed16 MOV segreg, reg16 *** Flag bits are not affected by MOV instruction

Examples.data count db 10 total dw 4126h bigVal dd h.code mov al, bl mov bl, count mov count, 26 mov bl, 1

Examples—cont… mov dx, cx mov bx, 8FE2h mov total, 1000h mov eax, ebx mov edx, bigVal ; 32-bit memory to reg ***Pay attention the the fact that operands size must match. Otherwise, the assembler will return an error for any size mismatch.

Example.data count dw 20h ; 20h---here really mean 0020h.code mov al, count; error:

XCHG Instruction XCHG reg, reg xchg ax, bx xchg eax, ebx XCHG reg, mem xchg ax, value1 XCHG mem, reg xchg value2, cx

Program example Title Exchange Two Variables (Exchange.asm).model small.stack 100h.data Value1 db 0ah Value2 db 14h.code Main proc Mov ; initialize DS register Mov ds, ax Mov al, value1 Xchg value2, al Mov value1, al Mov ax, 4c00h Int 21h Main endp End main; Question: Why don’t we use xchg value1, value2?

Arithmetic Instructions ADD and SUB instructions ADD reg, reg ADD mem, reg ADD reg, mem ADD reg, immed ADD mem, immed ADD accum, immed Flag O D I S Z A P C SUB has the similar instruction format * * *

Examples Mov ax, 10 Sub ax, 10 ; AX=0, ZF =1 Mov bx, 1 Sub bx, 2 ; BC = FFFF, SF = 1 Mov ax, 0FFh Add al, 1 ; AL = 00, CF = 1

Basic Operand Types There are three basic types of operands: 1. Immediate----a constant 2. Register one of the CPU’s register 3. Memory---a reference to a mem.Location There are six different types of memory operands: Direct, direct-offset, register-indirect Indexed, base-indexed, and base-indexed with displacement

Example mov ax, [si] --- this is called register-indirect Here si register hold the beginning address for a list of numbers. The first number in the address will be moved to al and the second number will be moved into ah.

Immediate operands, Direct Operands, and Direct-Offset operands 1. Immediate operands: Mov al, 10 ; ----a number Mov eax, h ; ---a 4-byte number Mov dl, ‘X’ ; --- a character Mov ax, (40 *50) ; arithmetic expression

Direct Operands.data Count db 20 Wordlist dw 1000h, 2000h LongVal dd h.code Mov al, Count Mov bx, Wordlist +2 Mov edx, LongVal

Direct Offset Operands.data Array db 0ah, 0bh, 0ch, 0dh.code Mov al, array ; 0ah-  al Mov bl, array +1 ; 0bh  bl Mov cl, array + 2 ; 0ch  cl Mov dl, array +3 ; 0dh  dl

Another Example

IA – 32 Processor Architecture IA – 32 processor have three basic mode of operations: 1. Protected Mode 2. Real-address Mode 3. System Management Mode

Protected Mode IA-32 processors have three basic modes of operation: Protected mode, Real-address mode and System Management mode. In addition, the Virtual-8086 mode is a special case of Protected mode.

1. Protected Mode Protected mode is the native state of the processor, in which all instructions and features are available. Programs are given separate memory areas (called segment), and the processor detects any attempt by a program to reference memory outside its assigned segment. Each program can address up to 4GB memory.

Virtual – 8086 Mode While in Protected mode, the processor can directly execute Real-address mode software such as MS-DOS programs in a safe multitasking environment. In other word, even if an MS-DOS program crashes, it will not affect other program running at the same time.

Real-address mode It offers us a few more features, such as the ability to switch into other two modes. Only 1 MB of memory can be addressed: 00000h-FFFFFh The processor can only run one program a time.

System Management Mode SSM-mode It provides an operating system with a mechanism for implementing such functions as power management and system security. These functions are usually implemented by computer manufacturers who want to customize the processor for a particular system setup.

Homework6 Write and run an assembly program under debug that will: 1) Add numbers from 1 to Note: you would need these following instructions: A) jz – jump if zero B) mov cx, number of times (1000 in Hex.) C) create the labels that tells program where to go when certain conditions are met. Due: 11/07 Turn in: Your code and the running result.

Note to the debug usage You can assemble your assembly language program with other software and load the code into the memory by using the debug as follows: Under debug: (Click start, click Run, type cmd and type enter) N a:hello.exe L This will load your code from a: to the memory address beginning at CS:0100.