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.

Slides:



Advertisements
Similar presentations
Assembly Programming Notes for Practical2 Munaf Sheikh
Advertisements

1 Assembly Instructions Assembly language instructions may involve mnemonics, labels, variables, constants, and directives. Examples are as follows. here.
Memory Address Segment-offset address Base location (segment) + logical location (offset) Example: For 32-bits segment-offset address, 08F1:0100 represents.
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.
Department of Computer Science and Software Engineering
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.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, MUL Instruction The MUL (unsigned multiply) instruction.
1 Using the Assembler Chapter 4 n Operators and Expressions n JMP and LOOP Instructions n Indirect Addressing n Using a Link Library.
Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, All rights reserved. You may modify and.
Assembly Language for Intel-Based Computers Chapter 8: Advanced Procedures Kip R. Irvine.
1 Lecture 4: Data Transfer, Addressing, and Arithmetic Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Target Processor Directives , When using.386, the program can only run on 386 and above processors.
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Symbolic Constants Equal-Sign Directive Calculating.
Irvine: Assembly Language for Intel-Based Computers (1999) Symbolic Constants Equal-sign Directive EQU Directive TEXTEQU Directive.
Assembly Language for Intel-Based Computers
Assembly Language Advantages 1. It reveals the secret of your computer’s hardware and software. 2. Speed. 3. Some special applications and occasions. Disadvantages.
Kip Irvine: Assembly Language for Intel-Based Computers Overview Stack Operations (PUSH and POP) Procedures Procedure Parameters Software Interrupts MS-DOS.
Assembly Language for Intel-Based Computers
Flow Control Instructions
Assembly Language for Intel-Based Computers Chapter 3: Assembly Language Fundamentals Kip Irvine.
Kip Irvine: Assembly Language for Intel-Based Computers
Assembly Language for Intel-Based Computers
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Stack Operations Runtime Stack PUSH Operation POP.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7)
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.
BIOS and DOS Programming in DOS INT 10 and 21H. Interrupts There are some extremely useful subroutines within BIOS or DOS that are available to the user.
Assembly Language for Intel-Based Computers, 6 th Edition Chapter 8: Advanced Procedures (c) Pearson Education, All rights reserved. You may.
Faculty of Engineering, Electrical Department,
Multiplication and Division Instructions & the 0Ah function.
CSC 221 Computer Organization and Assembly Language Lecture 27: 2-Dimensional Arrays + Structures.
Overview of Assembly Language Chapter 4 S. Dandamudi.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#9) By Dr. Syed Noman.
L AB 2. P ROGRAM STRUCTURE The assembly language program consist of code, data and stack. Data segment: contains all the variable definition..Data Code.
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.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
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.
Assembly Language for Intel-Based Computers Chapter 4: Data Transfers, Addressing, and Arithmetic Kip Irvine.
Irvine, Kip R. Assembly Language for Intel-Based Computers. Chapter 7: Integer Arithmetic Slides to Accompany Assembly Language for Intel-Based Computers,
Fall 2012 Chapter 4: Data Transfers, Addressing, and Arithmetic.
2/20/2016CAP 2211 Flow Control Instructions. 2/20/2016CAP 2212 Transfer of Control Flow control instructions are used to control the flow of a program.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Chapter 5: Procedures and Interrupts
Addressing Modes Dr. Hadi Hassan.  Two Basic Questions  Where are the operands?  How memory addresses are computed?  Intel IA-32 supports 3 fundamental.
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.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7) By Dr. Syed Noman.
Instruction set Architecture
Introduction to assembly programmıng language
Presentation on Real Mode Memory Addressing
Microprocessor and Assembly Language
Chapter 4 Data Movement Instructions
Lecture 4 Control Flow Structures (LOOPS)
Assembly Language for x86 Processors
Assembly Language for Intel-Based Computers, 4th Edition
Chapter 4: Instructions
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)
Assembly Language Programming
(Array and Addressing Modes)
Flow Control Instructions
Chapter 6 –Symbolic Instruction and Addressing
CS-401 Computer Architecture and Assembly Language Programming
(Array and Addressing Modes)
Presentation transcript:

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 ; loop counter mov si,offset string L1: mov ah,2 ; DOS function: display char mov dl,[si] ; get character from array int 21h ; display it now inc si ; point to next character Loop L1 ; decrement CX, repeat until 0 Displaying a String

Irvine, Kip R. Assembly Language For Intel-Based Computers.data intarray dw 0100h,0200h,0300h,0400h COUNT = ($ – intarray) / (TYPE intarray).code mov ax,0 ; zero accumulator mov di,offset intarray ; address of array mov cx,COUNT ; loop counter L1: add ax,[di] ; add an integer add di,TYPE intarray ; point to next integer Loop L1 ; repeat until CX = 0 Summing an Integer Array

Irvine, Kip R. Assembly Language For Intel-Based Computers Based and Indexed Operands The microsoft assembler permits the same address expression to be notated in various ways:

Irvine, Kip R. Assembly Language For Intel-Based Computers Two-Dimensional Array Example.data ROWSIZE = 5 array db 2h, 16h, 4h, 22h, 13h db 19h, 42h, 64h, 44h, 88h.code mov bx,ROWSIZE mov al,array[bx] ; AL = 19h Each row of this table contains five bytes. BX points to the beginning of the second row:

Irvine, Kip R. Assembly Language For Intel-Based Computers Based-Index Operands Add the value of a base register to an index register, producing an effective address of 0157: BX = 0155, SI = 0002 Example...

Irvine, Kip R. Assembly Language For Intel-Based Computers.data ROWSIZE = 5 array db 10h, 20h, 30h, 40h, 50h db 60h, 70h, 80h, 90h,0A0h db 0B0h,0C0h,0D0h,0E0h,0F0h.code mov bx,offset array ; point to the array at 0150 add bx,ROWSIZE ; choose second row mov si,2 ; choose third column mov al,[bx + si] ; get the value at 0157 Base-Index Example

Irvine, Kip R. Assembly Language For Intel-Based Computers Base-Index with Displacement.data ROWSIZE = 5 array db 10h, 20h, 30h, 40h, 50h db 60h, 70h, 80h, 90h,0A0h db 0B0h,0C0h,0D0h,0E0h,0F0h.code mov bx,ROWSIZE ; row 1 mov si,2 ; column 2 mov dl,array[bx + si] ; DL = 80h

Irvine, Kip R. Assembly Language For Intel-Based Computers Debugging Workshop

Irvine, Kip R. Assembly Language For Intel-Based Computers 1: title Mismatching Operand Sizes 2: 3:.model small 4:.stack 100h 5:.code 6: main proc 7:mov 8:mov ds,ax 9:mov ax,value1 10:mov ah,value2 11:mov ax,4C00h 12:int 21h 13:main endp 14: 15:.data 16: value1 db 0Ah 17: value2 dw 1000h 18: end main (9): warning A4031: Operand types must match (10): warning A4031: Operand types must match Mismatching Operand Sizes

Irvine, Kip R. Assembly Language For Intel-Based Computers 1: title Miscellaneous Errors Program 2: 3:.model small 4:.stack 100h 5:.code 6: main proc 7: mov 8: mov ds,ax 9: mov ax,bx * cx 10: mov bx,value1 * 2 11: mov byte ptr value3,al 12: mov cx,ax 13: mov cs,ds 14: mov ax,4C00h 15: int 21h 16: main endp 17:.data 18: value1 db 0Ah 19: value2 db 14h 20: value3 dw 1000h 21: end main Miscellaneous Errors

Irvine, Kip R. Assembly Language For Intel-Based Computers Intel386 and Intel486 Instructions MOVZX - Move with zero-extend –moves 8-bit operand into a 16-bit register, fills upper bits with zeros –moves 16-bit operand into a 32-bit register, fills upper bits with zeros MOVSX - Move with sign-extend –moves 8-bit operand into a 16-bit register, sign extends into upper bits –moves 16-bit operand into a 32-bit register, sign extends into upper bits

Irvine, Kip R. Assembly Language For Intel-Based Computers MOVZX and MOVSX Examples.data var16 dw 1234h var8 db -2; FEh.code mov bl,22h movzx ax,bl; AX = 0022h movzx edx,var16; EDX = h movsx cx,var8; CX = FFFEh