0% found this document useful (0 votes)
42 views12 pages

Chap5-Directive Statements (Compatibility Mode)

This document discusses directives and concepts for assembly language programming on the 8086 processor. It covers directives for defining data types (DB, DW, DD), naming variables, arrays, repeating data with DUP, storing word and doubleword data, symbolic constants with EQU, segment structure (data, code, stack), memory models, DOSSEG for segment ordering, and a basic program skeleton.

Uploaded by

Mhd Bazzi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views12 pages

Chap5-Directive Statements (Compatibility Mode)

This document discusses directives and concepts for assembly language programming on the 8086 processor. It covers directives for defining data types (DB, DW, DD), naming variables, arrays, repeating data with DUP, storing word and doubleword data, symbolic constants with EQU, segment structure (data, code, stack), memory models, DOSSEG for segment ordering, and a basic program skeleton.

Uploaded by

Mhd Bazzi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Directive statements to 8086

Assembly Language
Program Statements

• instructions - symbolic operation code


• directive - pseudo-operation code
• Comments begin with semicolon
• Most assemblers are not case sensitive

2/4/2015 Ali Saleh - Assembly Language Programming 2


Program Data and Storage

• DB - byte(s)
• DW - word(s)
• DD - doubleword(s)

2/4/2015 Ali Saleh - Assembly Language Programming 3


Naming Storage Locations

• Names can be associated


with storage locations
ANum DB -4
• ANum refers to a byte storage location,
x DW 17 initialized to FCh
UNO DW 1 • X is a word contains 17
y db ? • UNO is a word contains 1
• Y is an uninitialized byte
• These names are called
variables

2/4/2015 Ali Saleh - Assembly Language Programming 4


Arrays

• Any consecutive storage locations of the same size can be called an


array
X DW 40CH,10B,-13,0
Y DB 'This is an array'
Z DD -109236, FFFFFFFFH, -1, 100B

• Components of X are at X, X+2, X+4,X+6


• Components of Y are at Y, Y+1, …, Y+15
• Components of Z are at Z, Z+4, Z+8, Z+12

2/4/2015 Ali Saleh - Assembly Language Programming 5


DUP

• Allows a sequence of storage locations to be defined or reserved

X DB 40 DUP (?)
Y DW 10h DUP (0)
Z DB 3 dup (‘A’)

2/4/2015 Ali Saleh - Assembly Language Programming 6


Word Storage

• Word, and doubleword data are stored in reverse byte order


(in memory)

Directive Bytes in Storage


Z DW 256 00 01
Y DD 1234567H 67 45 23 01
X DW 35DAh DA 35

2/4/2015 Ali Saleh - Assembly Language Programming 7


EQU Directive

• name EQU expression


• expression can be string or numeric
• Use < and > to specify a string EQU
• these symbols cannot be redefined later in the program
sample EQU 7Fh
aString EQU <1.234>
message EQU <This is a message>

2/4/2015 Ali Saleh - Assembly Language Programming 8


Program Segment Structure

• Data Segments • Stack Segment


• Storage for variables • used to set aside storage
• Variable addresses are for the stack
computed as offsets from • Stack addresses are
start of this segment computed as offsets into
• Code Segment this segment
• contains executable • Segment directives
instructions .data
.code
.stack size

2/4/2015 Ali Saleh - Assembly Language Programming 9


Memory Models

• .Model memory_model
• tiny: code+data <= 64K (.com program)
• small: code<=64K, data<=64K, one of each
• medium: data<=64K, one data segment, multiple code
• compact: code<=64K, one code segment, multiple data
• large: multiple code and data segments
• huge: allows individual arrays to exceed 64K
• flat: no segments, 32-bit addresses, protected mode only (80386
and higher)

2/4/2015 Ali Saleh - Assembly Language Programming 10


Dosseg

• Dosseg directive : tells the assembler that we want the


segments of our program loaded in a very specific order.
• Code segment first and stack segment last

2/4/2015 Ali Saleh - Assembly Language Programming 11


Program Skeleton
dosseg
.model small
.stack 100H • Select a memory model
.data • Define the stack size
;declarations • Declare variables
.code • Write code
Mov ax,@data • organize into procedures
Mov ds,ax • Mark the end of the source file
Instructions…

Name1 proc
Proc inst.
Name1 endp
end

2/4/2015 Ali Saleh - Assembly Language Programming 12

You might also like