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.

Slides:



Advertisements
Similar presentations
Array : To store multiple value in one variable, “but value must be homogenous or similar type” is called array. We can say in other word Arrangement of.
Advertisements

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.
DOS and BIOS Interrupts DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from.
There are two types of addressing schemes:
Assembly Programming Notes for Practical2 Munaf Sheikh
Addressing modes The way in which an operand is specified is called the Address Mode.
1 Assembly Instructions Assembly language instructions may involve mnemonics, labels, variables, constants, and directives. Examples are as follows. here.
1/2002JNM1 AL 00 Immediate Addressing Mode Mov AL, 3CH AL 3C.
6-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Intel 8088 Addressing modes.
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.
Irvine, Kip R. Assembly Language For Intel-Based Computers TYPE and SIZE Operators TYPE –returns the size, in bytes of a single element of a data label.
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
Azir ALIU 1 What is an assembly language?. Azir ALIU 2 Inside the CPU.
Handout 2 Digital System Engineering (EE-390)
Addressing modes – 1 The way in which an operand is specified is called the Address Mode.
The 8086 Assembly Programming Data Allocation & Addressing Modes
Addressing Modes Instruction – Op-code – Operand Addressing mode indicates a way of locating data or operands. – Any instruction may belong to one or more.
Target Processor Directives , When using.386, the program can only run on 386 and above processors.
Flow Control Instructions
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
INTRODUCTION TO IBM PC 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
Stack Operations LIFO structure (last-in,first-out) –The last value put into the stack is the first value taken out Runtime stack –A memory array that.
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.
Types of Registers (8086 Microprocessor Based)
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Strings, Procedures and Macros
ICS312 Lecture13 String Instructions.
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.
10H Interrupt. Option 0H – Sets video mode. Registers used: – AH = 0H – AL = Video Mode. 3H - CGA Color text of 80X25 7H - Monochrome text of 80X25 Ex:
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.
Review of Assembly language. Recalling main concepts.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
File Operations. FILE PROCESSING For the purposes of the following discussion, reading means copying all or part of an existing file into memory Writing.
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.
Addressing Modes Instruction – Op-code – Operand Addressing mode indicates a way of locating data or operands. – Any instruction may belong to one or more.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Assembly language programming
Instruction set Architecture
Format of Assembly language
Presentation on Real Mode Memory Addressing
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
Additional Assembly Programming Concepts
ADDRESSING MODES.
Microprocessor and Assembly Language
Lecture 4 Control Flow Structures (LOOPS)
Assembly IA-32.
ADDRESSING MODES.
Assembly Lang. – Intel 8086 Addressing modes – 1
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Microprocessor and Assembly Language
Arithmetic Instructions
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Introduction to Assembly Language
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
8086 Registers Module M14.2 Sections 9.2, 10.1.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
(Array and Addressing Modes)
Symbolic Instruction and Addressing
(Array and Addressing Modes)
CNET 315 Microprocessor & Assembly Language
Chapter 6 –Symbolic Instruction and Addressing
Chapter 8: Instruction Set 8086 CPU Architecture
(Array and Addressing Modes)
Presentation transcript:

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 register AX. Immediate Operands. A constant is an immediate operand. MOV AX, 5 ; moves the numeric value 5 into AX MOV ; moves the constant represented into AX Direct Operands. A variable name that represents a memory address is a direct (memory) operand. MOV BX, NUM ; moves the contents of the memory variable ; NUM into BX

Basic Operand Types (2) A variable name +/- a numeric offset MOV BX, NUM+2 ; moves 2nd byte following NUM into BX Useful for array addressing OFFSET operator: returns the 16-bit offset (address) of a memory variable. MOV BX, OFFSET NUM ; puts offset address of NUM into BX LEA instruction: stores the address of a memory variable in a general register. Same effect as instruction above obtained by: LEA BX, NUM ; puts offset address of NUM into BX

Basic Operand Types (3) Examples. Identify the types of ALL operands used in each line of the following code:.DATA CRLF EQU 0AH, 0DH VAR1 DW 1200H, 56H, 0FFFFH MSG DB 'The answer is: ', '$‘.CODE MOV MOV DX, AX MOV AX, OFFSET VAR1 ADD BH, 15 LEA BX, VAR1+2 MOV DX, OFFSET MSG MOV AH, 9 INT 21H MOV AX, 4C00H INT 21H

An indirect operand is an offset of a variable, which is contained in a register. The register acts as a pointer to the variable involved. The 16-bit registers used for indirect addressing are: SI, DI, BX, and BP Any of the general purpose 32-bit registers may be used. Default segments: For SI, DI, and BX the variable involved is assumed to be in the Data segment. For BP, the variable involved is assumed to be in the stack segment. Segment Overrides: Use a Segment Override Prefix to designate which segment to use when the default segment is not appropriate: mov al, cs:[si] ; uses SI as an offset into the Code segment, ; instead of the Data segment mov dx, ds:[bp] ; uses BP as an offset into the Data segment, ; instead of the Stack segment.

An example of the use of an indirect operand is: mov ax, [BX] Note that BX is enclosed within square brackets. If BX contains e.g. 4, then the no. moved into ax is not 4, but the value of the word located at offset 4 in the data segment. E.g. if the data segment was:.DATA x dw 100 ; x is at offset 0 y dw 250 ; y is at offset 2 z dw 300 ; z is at offset 4 k dw 99 ; k is at offset 6 then the no. moved into ax would be 300.

Indirect Operands (2) Example: To add up the items in List & store the answer in sum..data sum db 0 List db 10h, 20h, 30h, 40h Method 1: increment bx to advance to each value.code lea bx, List ;in this example, sets bx to 1 mov al, [bx] ; al = 10h inc bx ; bx is 2 and so points to 20h add al, [bx] ; al = 30h inc bx ; bx points to 30h add al, [bx] ; al = 60h inc bx ; bx points to 40h add al, [bx] ; al = 0A0h movsum, al

.data Sum db 0 List db10h, 20h, 30h, 40h Method 2: use bx with displacements to access each value.code lea bx, List mov al, [bx] ; AL = 10h add al, [bx+1] ; AL = 30h add al, [bx+2] ; AL = 60h add al, [bx+3] ; AL = 0A0h mov sum, al ; store sum in next memory location (sum)

Examples of different indirect operand formats mov ax, [bx] mov dx, [bx+10] mov cx, array[bx] ; same as mov cx [bx+array] ; array is a constant equal to the ; array’s offset mov ax, [di] mov dx, [di + 2*5] mov cx, [array+si]

Example: code to display contents of an array (message) using only function 2 and the loop instruction:.data message db "Hello, World!", 0Ah, 0Dh count equ $-message ; length of message.code mov si, 0 ; initialize offset to 0 mov ah, 2 ; function to display a character on screen mov cx, count ; cx = message length L_top: mov dl, message[si] ; move character into dl int 21h ; display character inc si ; set si to offset of next character loop L_top ; repeat until count = 0 Note: instead of: mov si,0 … mov dl,message[si], we could have used: lea si,message … mov dl,[si]

Examples requiring use of PTR ByteVal DB 05h, 06h, 08h, 09h, 0Ah, 0Dh, '$' WordVal DW 5510h, 6620h, 0A0Dh, '$' LEA BX, WordVal ; or: MOV BX, OFFSET WordVal ; BX points to WordVal MOV WORD PTR [BX+2], 7 ; Replaces 6620h by 0007h The PTR operator is used to explicitly state the size of an operand that would otherwise be ambiguous, in particular when the first operand is indirect, and the second is immediate LEA BX, ByteVal+2 ;Puts offset of the 08h into BX MOV BYTE PTR [BX], 2 ; Replace 08h by 02h INC BYTE PRT [BX] ; Increments the 02H to 03H

Textbook Reading (Jones): Chapter 10 Arrays