Memory model ModelDescription SMALLCode in one segment Data in one segment MEDIUMCode in > 1 segment Data in one segment COMPACTCode in one segment Data.

Slides:



Advertisements
Similar presentations
There are two types of addressing schemes:
Advertisements

NEG Instruction Change operand content into two’s complement (negative value) and stored back into its operand mov bl, b neg bl; bl = mov.
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.
Department of Computer Science and Software Engineering
Subroutines: Passing Arguments Using the Stack. Passing Arguments via the Stack Arguments to a subroutine are pushed onto the stack. The subroutine accesses.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
The 8086 Assembly Programming Data Allocation & Addressing Modes
Assembly 02. Outline mov Command Registers Memory EFLAGS Arithmetic 1.
Irvine: Assembly Language for Intel-Based Computers (1999) Symbolic Constants Equal-sign Directive EQU Directive TEXTEQU Directive.
Kip Irvine: Assembly Language for Intel-Based Computers Overview Stack Operations (PUSH and POP) Procedures Procedure Parameters Software Interrupts MS-DOS.
CS2422 Assembly Language & System Programming September 28, 2006.
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
Assembly Language – Lab 5
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 ;
Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External 2. The type.
ASSEMBLY LANGUAGE. Assembler and Compiler Pascal A Program Compiler Version A Assembly Language Versiion A Machine Code Actual version that will be executed.
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.
Faculty of Engineering, Electrical Department,
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.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
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.
21/11/2005CAP2411 Input & Output Instructions CPU communicates with the peripherals through I/O registers called I/O ports. There are 2 instructions, IN.
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.
زبان ماشین و اسمبلی – درس نهم روشهای آدرسدهی دانشگاه آزاد اسلامی – مشهد علمی.
Overview of Assembly Language Chapter 4 S. Dandamudi.
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.
Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.
B ASIC INSTRUCTIONS. I NTRODUCTION There are over a hundred instructions in the instruction set for the 8086 CPU; there are also instructions designed.
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.
Data Transfer Instructions Introduction The data transfer instructions are used to move data between internal register or between internal.
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.
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
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
Data Transfers, Addressing, and Arithmetic
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
Microprocessor and Assembly Language
Microprocessor and Assembly Language
Assembly Language Programming Part 2
Computer Organization & Assembly Language
(The Stack and Procedures)
INSTRUCTION SET OF 8086 PAWAN KUMAR SINGH.
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
X86’s instruction sets.
Introduction to Assembly Language
Chapter 4: Instructions
3.6 Data transfer Instructions
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
(The Stack and Procedures)
Symbolic Instruction and Addressing
Flow Control Instructions
Morgan Kaufmann Publishers Computer Organization and Assembly Language
University of Gujrat Department of Computer Science
Assembler Directives end label end of program, label is entry point
Chapter 6 –Symbolic Instruction and Addressing
(The Stack and Procedures)
Introduction to 8086 Assembly Language
Procedures & Macros Introduction Syntax Difference.
Presentation transcript:

Memory model ModelDescription SMALLCode in one segment Data in one segment MEDIUMCode in > 1 segment Data in one segment COMPACTCode in one segment Data in > 1 segment LARGECode in > one segment Data in > 1 segment Array is not more than 64KB HUGECode in > 1 segment Data in > one segment Aray is larger than 64KB

Data Segment Contain all variable declaration To declare data segment, directive.DATA, followed by variable or constant declaration E.g. –.DATA –WORD1DW2 –WORD2DW5 –MSGDB ‘INI ADALAH MESEJ’ –MASKEQU B

Stack Segment Is used to reserve one memory block to store stack Definition syntax.STACKsize(size is optional) E.g:.STACK100H The above statement will prepare 100h byte for stack area

Code Segment Contain program instructions Syntax declaration.CODEname;where name is ;the chosen of ;the segment Instruction is in procedure form

Simple procedure declaration: namePROC ; procedure body nameENDP where name (procedure name); PROC and ENDP (pseudo-op which describe procedure)

Eg:.CODE MAIN PROC ;main procedure instruction MAIN ENDP ;other procedure starts here

Combination of segments One general form programming model using memory model..SMALL can be constructed.MODELSMALL STACK100H.DATA ;data declaration starts here.CODE MAINPROC ;instruction starts here MAINENDP ;other procedures starts here ENDMAIN Last line must be END, followed by main procedure name

8086 Instruction Set

Instruction Types Data transfer instruction Arithmetic instruction Bit control instruction Compare instruction Jump/branch instruction Loop instruction

Data Transfer Instruction Used to transfer data –Between one internal register with other internal register –Between internal register with one storage location in memory –Between one internal register with immediate value Instructions such as MOV and XCHG

MOV (MOVe) Transfer from source operand to destination operand Format MOV OD, OS;where OS= source ;operand ;OD=destination ;operand Execution example Source OperandDestination Operand Before operationXXXYYY After operationXXX

Destination operand Source operandExample General register MOV AX, BX Segment registerGeneral registerMOV DS, AX MemoryRegisterMOV [BX],AX General registerMemoryMOV AX,BETA RegisterConstant /immediate value MOV AX,5H MemoryConstant /immediate value MOV [BX],45H General registerSegment registerMOV AX,DS Segment registerMemoryMOV DS,[BX] MemoryConstant /immediate value MOV [BX],25H Valid source and destination operand

To transfer both source and destination operand which is the memory space can be done with instruction MOV AX,BETA ;copy BETA content into AX MOV ALPHA,AX ;copy AX content into ;ALPHA Transger must be between equivalent data size, example: MOV AL,1234H ;is not allowed because ;insert data with 16-bit size ;into 8-bit size register

Example copy MOV instruction with register addressing mode and direct addressing mode –Register addressing mode MOV AX,BX  (BX)  (AX) –Direct addressing mode MOV CX,[ABCD]  ((DS)OH+ABCD)  (CL) ((DS)OH+ABCD+1)  (CH)

XCHG (EXCHange) Exchangfe between source operand with destination operand Format XCHG OD,OS ;where OD=destination ;operand ;OS=source operand Instruction execution XCHG AX,DX AXDX BeforeXXXYYY AfterYYYXXX

Can involve 8 and 16 bit data but size must be equivalent For instruction involve memory space like XCHG [SUM],BX exchange is as XCHG [SUM],BX  ((DS)OH+SUM)  BX

Exchange 2 variable 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 ; load the AL register xchg value2,al ; exchange AL and value2 mov value1,al ; store AL back into value1 mov ax,4C00h ; exit program int 21h main endp end main

Arithmetic Instruction Involve additional instruction (ADD), subtraction (SUB), multiplication (MUL) and division (DIV) Also contain this instruction variation For instruction such as ADC instruction including carry flag instruction

ADD (ADDition) Perform addition between source operand and destination operand and result is stored in operand destination Format ADD OD,OS ;where OD=destination ;operand ;OS=source operand ADD OD,OS OD+OS  OD (if there is a carry, carry flag, CF=1)

ADD instruction Source operand can be register, immediate value or memory Destination operand can be register or memory Only one operand can be memory operand

ADD Instruction Examples.data membyte db 25 memword dw 36 doubleVal dd h.code add al,5 add bx,ax add eax,edx add membyte,al add memword,bx add doubleVal,edx

Valid destination operand and source operand combination Destination operand Source operandInstruction example General register ADD AX,DX MemoryGeneral registerADD [BX],AX General registerMemoryADD AX,[BX] Immediate valueGeneral registerADD AX,35 Immediate valueMemoryADD BYTE PTR [BX],5H

Instruction example If AX=1234H, BX=0001H, therefore ADD AX,BX is as in the table below AXBXCarry Flag 1Before1234H0001Hx After1235H0001H0 2Before1234HEF00Hx After0134HEF00H1

SUB Instruction Format : SUB OD, OS ;where OS source operand ;OD destination operand Subtract source operand from destination operand Source operand can be register, immediate value or memory Destination operand can be register or memory Only one operand can be memory operand

SUB Instruction Example.data membyte db 25 memword dw 36 doubleVal dd h.code sub al,5 sub bx,ax sub eax,edx sub membyte,al sub memword,bx sub doubleVal,edx