Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.

Slides:



Advertisements
Similar presentations
COMP 2003: Assembly Language and Digital Logic
Advertisements

Assembly Programming Notes for Practical2 Munaf Sheikh
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.
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
The 8086 Assembly Programming Data Allocation & Addressing Modes
Assembly 02. Outline mov Command Registers Memory EFLAGS Arithmetic 1.
Computer Organization And Assembly Language
Joseph L. Lindo Assembly Programming Sir Joseph Lindo University of the Cordilleras.
1 Lecture 4: Data Transfer, Addressing, and Arithmetic Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Microprocessor Systems Design I
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
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 7: More on Addressing Modes, Structures, and Stack Constantine D. Polychronopoulos Professor, ECE.
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.
Introduction to 8086 Assembly Language Assembly Language Programming University of Akron Dr. Tim Margush.
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
The x86 Architecture Lecture 15 Fri, Mar 4, 2005.
Computer Architecture and Assembly Language. Byte structure : a byte has 8 bits MSB (Most Significant Bit) LSB (Least Significant Bit) Data Representation.
CET 3510 Microcomputer Systems Tech. Lecture 2 Professor: Dr. José M. Reyes Álamo.
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.
Computer Architecture and Assembly Language
Assembly 09. Outline Strings in x86 esi, edi, ecx, eax stosb, stosw, stosd cld, std rep loop 1.
Arrays. Outline 1.(Introduction) Arrays An array is a contiguous block of list of data in memory. Each element of the list must be the same type and use.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Homework Reading Lab with your assigned section starts next week
Credits and Disclaimers
Format of Assembly language
Assembly Lab 3.
Data Transfers, Addressing, and Arithmetic
Additional Assembly Programming Concepts
Chapter 4 Data Movement Instructions
Microprocessor and Assembly Language
Assembly IA-32.
Homework Reading Continue work on mp1
INTRODUCTION ABOUT ASSEMBLY
Computer Organization & Assembly Language
Assembly Language for x86 Processors
Arithmetic Instructions
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Chapter 4: Instructions
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
Chapter 4 –Requirements for coding in Assembly Language
University of Gujrat Department of Computer Science
Computer Architecture CST 250
Requirements for coding in Assembly Language
X86 Assembly Review.
Chapter 5 Arithmetic and Logic Instructions
Assembler Directives end label end of program, label is entry point
Computer Architecture and System Programming Laboratory
Chapter 6 –Symbolic Instruction and Addressing
CSC 497/583 Advanced Topics in Computer Security
Credits and Disclaimers
Computer Architecture and Assembly Language
Introduction to 8086 Assembly Language
Computer Architecture and System Programming Laboratory
Presentation transcript:

Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed

DB-define byte DW-define word DD-define double word (two consecutive words) DQ- define quadword (four consecutive words) DT-define ten consecutive bytes.DATA directive

Name Type initial_value Var DB 64 ;Declare a byte, referred to as location var, containing the value 64. Var2 DB ? ;Declare an uninitialized byte, referred to as location var2. DB 10 ;Declare a byte with no label, containing the value 10. Its location is var X DW ? ; Declare a 2-byte uninitialized value, referred to as location X. Y DD ; Declare a 4-byte value, referred to as location Y, initialized to Declaration of Assembly Language

Two Words Contains a blank 2abc Begins with a digit A Is not allowed You&me contain an illegal character Illegal Variable Names

On the bases of operands instructions can be divided into three types – No operands e.g NOP – One operands e.g INC AX – Two operands e.g ADD Word1,2 In two operands instructions first operand is as destination where result is stored Second operand is source operand source is not usually modified after completion of instruction Types of Instructions

Programmer use comments to say something about code ; symbol is use to define comment This symbol is use at the start of each statement on which we want to apply comments. Assembler will ignore the statements typed after ; MOV CX,0 ;mov 0 in CX register Comments in Assembly

Processor can only operate on binary numbers but Assembler can accept Binary, Decimal and Hex numbers B or b is use at the end to define binary D or d is use at the end to define decimal H or h is use at the end to define Hex Hex number must begin with decimal and end with H Program data (Numbers)

Examples Decimal BBinary Decimal DDecimal 1,2212Illegal 173BHHexadecimal FFFFHIllegal 0FFFFHHexadecimal Program data (Numbers)

Any 32-bit register (EAX, EBX, ECX, EDX, ESI, EDI, ESP, or EBP) Any 16-bit register (AX, BX, CX, or DX) Any 8-bit register (AH, BH, CH, DH, AL, BL, CL, or DL) Any register A memory address (e.g., [eax], [var + 4], or dword ptr [eax+ebx]) Any 32-bit constant Any 16-bit constant Any 8-bit constant Any 8-, 16-, or 32-bit constant Instructions

The mov instruction copies the data item referred to by its second operand (i.e. register contents, memory contents, or a constant value) into the location referred to by its first operand Data Movement Instructions

Syntax mov, mov, mov, mov, mov, Examples mov eax, ebx — copy the value in ebx into eax mov byte ptr [var], 5 — store the value 5 into the byte at location var Data Movement Instructions

MOV

Size of both operand of mov instruction must be same But, in some cases these may be imbegious like, mov [ebx], 2. Size Directives

mov BYTE PTR [ebx], 2; Move 2 into the single byte at the address stored in EBX. mov WORD PTR [ebx], 2; Move the 16-bit integer representation of 2 into the 2 bytes starting at the address in EBX. mov DWORD PTR [ebx], 2 ; Move the 32-bit integer representation of 2 into the 4 bytes starting at the address in EBX. Size Directives

XCHG, exchange is use to exchange the content of two operands XCHG Destination, Source XCHG instruction

The sub instruction stores in the value of its first operand the result of subtracting the value of its second operand from the value of its first operand Syntax add, add, add, add, add, Examples add eax, 10 — EAX ← EAX + 10 add BYTE PTR [var], 10 — add 10 to the single byte stored at memory address var Add Instruction

The sub instruction stores in the value of its first operand the result of subtracting the value of its second operand from the value of its first operand Syntax sub, sub, sub, sub, sub, Examples sub al, ah — AL ← AL - AH sub eax, 216 — subtract 216 from the value stored in EAX Sub Instruction

The inc instruction increments the contents of its operand by one The dec instruction decrements the contents of its operand by one. inc, dec — Increment, Decrement

Syntax inc inc dec dec Examples dec eax — subtract one from the contents of EAX. inc DWORD PTR [var] — add one to the 32-bit integer stored at location var inc, dec — Increment, Decrement

ADD, SUB, INC and DEC

Thanks