Defining Types of data expression Dn [name] expression Dn [name]

Slides:



Advertisements
Similar presentations
Register In computer architecture, a processor register is a small amount of storage available on the CPU whose contents can be accessed more quickly than.
Advertisements

Assembly Programming Notes for Practical2 Munaf Sheikh
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
ICS312 Set 6 Operands. Basic Operand Types (1) Register Operands. An operand that refers to a register. MOV AX, BX ; moves contents of register BX to.
Video systems (continue). Practice Modify the program to get a string from a keyboard to display the input string on the middle of the screen with reverse.
Azir ALIU 1 What is an assembly language?. Azir ALIU 2 Inside the CPU.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
The 8086 Assembly Programming Data Allocation & Addressing Modes
80x86 Processor Architecture
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
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 ;
An Introduction to 8086 Microprocessor.
ASSEMBLY LANGUAGE. Assembler and Compiler Pascal A Program Compiler Version A Assembly Language Versiion A Machine Code Actual version that will be executed.
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.
Types of Registers (8086 Microprocessor Based)
Review of Assembly language. Recalling main concepts.
Lecture 2 Chapter 4 –Requirements for coding in Assembly Language 1.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Assembly Language Lecture 2. Lecture Outline Program Structure Memory models Data Segment Stack Segment Code Segment Input and Output Instructions INT.
Internal Programming Architecture or Model
Preliminary to Assembly Language Programming CE 140 A1/A2 28 June 2003.
Assembly language programming
Instruction set Architecture
Format of Assembly language
Introduction to 8086 Microprocessor
8086 Microprocessor.
Computer Organization & Assembly Language Chapter 3
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
Microprocessor and Assembly Language
ADDRESSING MODES.
University of Gujrat Department of Computer Science
Intel 8088 (8086) Microprocessor Structure
INTRODUCTION ABOUT ASSEMBLY
Computer Organization & Assembly Language
Morgan Kaufmann Publishers Computer Organization and Assembly Language
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.
Intel 8088 (8086) Microprocessor Structure
8086 Registers Module M14.2 Sections 9.2, 10.1.
CS-401 Computer Architecture & Assembly Language Programming
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Shift & Rotate Instructions)
The Microprocessor & Its Architecture
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Chapter 4 –Requirements for coding in Assembly Language
INTRODUCTION ABOUT ASSEMBLY
Lecture 06 Programming language.
Chapter 4 –Requirements for coding in Assembly Language
Computer Architecture CST 250
Requirements for coding in Assembly Language
Unit-I 80386DX Architecture
Assembler Directives end label end of program, label is entry point
Chapter 6 –Symbolic Instruction and Addressing
Process.
Intel 8086.
By Nasser Halasa Assembly Language.
Chapter 8: Instruction Set 8086 CPU Architecture
Introduction to 8086 Assembly Language
Part I Data Representation and 8086 Microprocessors
(Array and Addressing Modes)
Presentation transcript:

Defining Types of data expression Dn [name] expression Dn [name] Name: a program that references a data item does so by means of name Dn (Directive): define the data item – see next slide— Expression: is an operand may specify an uninitialized value or constant value an uninitialized value defined by item ? EXAMPLE : DATAX DB ?

Defining Types of data (Directive): Pseudo-op Stands for DB Define Byte DW Define Word DD Define Doubleword DQ Define Quadword DT Define Tenbytes

Defining Types of data -Examples a memory byte is associated with the name ALPHA, and initialized to 4 ALPHA DB 4 A memory byte is associated with the name BYT, and uninitialized. BYT DB ? a memory word is associated with the name WRD, and initialized to -2. WRD DW -2

High and Low Bytes of a Word WORD1 DW 1234H high byte WORD1+1 low byte WORD1

Defining Types of data The decimal range (fit a byte): Unsigned representation: 0 to 255 Signed representation: -128 to 127 The decimal range (fit a word): Unsigned representation: 0 to 65535 Signed representation: -32768 to 32767

Defining Types of data – Array byte an array is a sequence of memory bytes or words. Example: B_ARRAY DB 10H,20H,30H Symbol Address Contents B_ARRAY 200H 10H B_ARRAY+1 201H 20H B_ARRAY+2 202H 30H

Defining Types of data – Array word Example: W_ARRAY DW 1000,40,29887,329 Symbol Address Contents W_ARRAY 0300H 1000D W_ARRAY+2 0302H 40D W_ARRAY+4 0304H 29887D W_ARRAY+6 0306H 329D

Defining Types of data :The DUP Operator It is possible to define arrays whose elements share a common initial value by using the DUP (duplicate) operator. Syntax: Example: Repeat-count(exp) Dn [name] creates an array of 212 uninitialized bytes. DELTA DB 212 DUP (?) set up an array of 100 words, with each entry initialized to 0. GAMMA DW 100 DUP (0)

Character String ASCII codes can be initialized with a string of characters using single quotes like ‘PC’ or double quotes like “PC”. Example: LETTERS DB 'ABC' = LETTERS DB 41H,42H,43H Inside a string, the assembler differentiates between upper and lowercase. It is possible to combine characters and numbers in one definition: Example: MSG DB 'HELLO',0AH,0DH, '$'

Exercises: Q1. Which of the following names are legal ? a. ?1 b. T = c. LET’S_GO Q2. If it is legal, give data definition pseudo-op to define each of the following. A word variable A initialized to 52. A byte variable C initialized to 300. A word variable WORD1,unintialized. A byte variable B initialized to -129.

Numeric Constant In an assembly language program we may express data as: Binary: bit string followed by ‘B’ or ‘b’ Decimal: string of decimal digits followed by an optional ‘D’ or ‘d’ Hex: begins with a decimal digit and ends with ‘H’ or ‘h’ Real : end with ‘R’ and the assembler converts a given a decimal or hex constant to floating point number Any number may have an optional sign.

Numeric Constant Number Type 11011 1101B 64223 decimal -21843D 1B4DH FFFFH 0FFFFH decimal binary decimal decimal hex illegal illegal hex

Named Constants - EQU (Equates) To assign a name to a constant, we can use the EQU pseudo-op. Syntax: name EQU constant Examples: LF EQU 0AH MOV DL,0AH = MOV DL,LF PROMPT EQU 'Any Thing' MSG DB 'Any Thing' = MSG DB PROMPT Note: no memory is allocated for EQU names.

Registers Information inside the microprocessor is stored in registers. The registers are classified according to the functions they perform In general there are fourteen 16-bit registers: Data registers: There are four general data registers. They hold data for an operation. Address registers: They are divided into segment, pointer, and index registers. They hold the address of an instruction or data. Status register: It is called the FLAGS register. It keeps the current status of the processor.

Pointer and Index Registers Data Registers AX AH AL BH BL BX CX CH CL DX DH DL Segment Registers CS DS SS ES Pointer and Index Registers SI DI SP BP IP FLAGS Register

Data Registers: AX, BX, CX, DX These four registers, in addition to being general-purpose registers, also perform special functions. The high and low bytes of these registers can be accessed separately. Ex. The high byte of AX is called AH, and the low byte is called AL. This arrangement gives us more registers to use when dealing with byte-size data.

Data Registers: AX, BX, CX, DX AX (Accumulator Register) is the preferred register to use in arithmetic, logic, and data transfer instructions BX (Base Register) also serves as an address register. CX (Count Register) Program loop constructions are facilitated by the use of CX, which serves as a loop counter. DX (Data Register) is used in multiplication and division.

Address Registers - Segment Registers CS, DS, SS, ES To keep track of the various program segments, the 8086 is equipped with four segments registers to hold segment numbers: CS (Code Segment): contains the code segment number. DS (Data segment): contains the data segment number. SS (Stack Segment): contains the stack segment number. ES (Extra Segment): is used if a program needs to access a second data segment.

MOV Instruction The MOV (move) instruction is used to: Transfer data between Registers. Transfer data between registers and memory locations. Move a number directly into a register or memory location. Syntax: MOV destination, source Example: MOV AX, WORD1 MOV AX, BX MOV AX, 'A' Note: any register can be used except CS & IP Before After 0006 0008 AX AX 0008 0008 WORD1 WORD1

Legal Combinations of operands for MOV Destination Operand General Segment Memory Source operand register register location Constant General register yes yes yes no Segment register yes no yes no Memory location yes yes no no Constant yes no yes no Illegal: MOV WORD1, WORD2 • Legal: MOV AX, WORD2 MOV WORD1, AX Illegal: MOV DS, CS • Legal: MOV AX, CS MOV DS, AX

Type Agreement of Operands The operands of any two-operand instruction must be of the same type (i.e. Both bytes or words). Illegal: MOV AX, BYTE1 However, the assembler will accept both of the following: MOV AH, 'A' moves 41H into AH MOV AX, 'A' moves 0041H into AX

LEA Instruction LEA (Load Effective Address) puts a copy of the source offset address into the destination. Syntax: LEA destination, source Where destination is a general register and source is a memory location Example: MSG DB 41H, 42H, 43H LEA DX, MSG puts the offset address of the variable MSG into DX. Data Definition + Basic Instructions 17

ADD and SUB Instructions The ADD (add) and SUB (subtract) instructions are used to: Add/subtract the contents of: Two registers. A register and a memory location. Add/subtract a number to/from a register or memory location. Syntax: ADD destination, source SUB destination, source Examples: ADD WORD1, AX SUB AX, DX Before After 01BC 01BC AX AX 0523 06DF WORD1 WORD1 Before After 0000 FFFF AX AX 0001 0001 DX DX

Legal Combinations of operands for ADD & SUB Destination Operand General Memory Source Operand register location General register yes yes Memory location yes no Constant yes yes Illegal: ADD BYTE1, BYTE2 Legal: MOV AL, BYTE2 ADD BYTE1, AL

INT Instruction To invoke a DOS or BIOS routine, the INT (interrupt) instruction is used. Format: INT interrupt_number where interrupt_number is a number that specifies a routine.

INT 21h INT 21h may be used to invoke a large number of DOS functions. A particular function is requested by placing a function number in the AH register and invoking INT 21h. Some of the functions are: INT21h functions expect input values to be in certain registers and return output values in other registers. Function number Routine 1 single-key input 2 single-character output 9 character string output

INT 21h Function 1: Single-Key Input Input: AH = 1 Output: AL = ASCII code if character key is pressed = 0 if non-character key is pressed To invoke the routine, the following instructions should be executed: MOV AH,1 ; input key function INT 21H ; ASCII code in AL

INT 21h Function 2: Display a character or execute a control function Input: AH = 2 DL = ASCII code of the character Output AL = ASCII code of the character To invoke the routine, the following instructions should be executed: MOV AH, 2 ; display character function MOV DL, '?' ; character is '?' (or any other character) INT 21H ; display character

INT 21h Function 2 may be used to perform control functions. If DL contains the ASCII code of a control character, INT 21h causes the control function to be performed. The principal control characters are : ASCII code (Hex) Symbol Function 07H BEL beep (sounds a tone) 08H BS backspace 09H HT tab 0AH LF line feed (new line) 0DH CR carriage return (start of current line)

INT 21h Function 9: Display a string Input: AH = 9 DX = offset address of string. The string must end with a '$' character To invoke the routine, the following instructions should be executed: MOV AX, @DATA MOV DS, AX MOV AH, 9 ; display string function LEA DX, MSG ; get message (Load Effective Address) INT 21H ; display string A program containing a data segment should begins with these two instructions