Skip to content
Get App

Assembler Directives/Pseudo Codes in 8086 Microprocessor | 8086 Programming

Engineering Funda explains 8086 assembler directives (pseudo-opcodes): why they matter, segment definitions, ASSUME, PROC/MACRO, data definitions like DB/DW/EQU, and pointers.

Key Takeaways

  • Assembler directives are essential syntax the assembler needs to produce machine code, and they cannot be executed.
  • Segments must be declared and assigned through SEGMENT/ENDS and ASSUME, with START/END structuring the program.
  • Procedures (CALL) and macros (name invocation) are two ways to reuse code, with macros expanded inline.
  • Choosing the correct data definition directive (DB, DW, EQU, etc.) and size pointer (BYTE PTR, WORD PTR) is necessary for correct data handling on the 8086.

What the video covers

  • Assembler directives (pseudo-opcodes) are not executed as instructions; they guide the assembler in converting assembly code into machine code.
  • Learning directives is a prerequisite for writing 8086 assembly programs, even if you know the instruction set.
  • SEGMENT and ENDS define segments; the segment name does not by itself imply its type (e.g., a segment named 'data' is not automatically a data segment).
  • ASSUME associates logical segment names with the CS, DS, and other segment registers.
  • The 8086 has four segment types: data, code, extra, and stack.
  • END marks the end of the program; anything after it is ignored by the assembler. START/END START delimit the executable assembly code.
  • PROC/ENDP define procedures called with CALL; MACRO/ENDM define macros invoked by simply writing their name.
  • Data directives DB, DW, DD, DQ, DT define byte, word, double word, quad word, and ten-byte values; EQU defines constants that cannot be changed.
  • DUP duplicates values for array definitions; the 8086 being a 16-bit processor, word alignment at even addresses improves speed.
  • BYTE PTR and WORD PTR specify operand size; OFFSET, LEA, NEAR, FAR, and memory models (small, large) are also covered.

Answers

Questions about this video

Why are assembler directives called pseudo opcodes?

They are called pseudo opcodes because they look like instructions but cannot be executed by the processor. They are only used by the assembler to convert the program into machine code.

What is the difference between a procedure and a macro in 8086 assembly?

A procedure is invoked with the CALL instruction, while a macro is invoked simply by writing its label in the program. The video says a separate video covers the detailed differences.

Why should data be aligned at even memory addresses on the 8086?

Because the 8086 is a 16-bit processor, word data at even addresses can be accessed in a single machine cycle, which increases execution speed.

Full Transcript — Download SRT & Markdown

00:00
Speaker A
Welcome to engineering fun family. This video is a part of microprocessor 80086 video lecture series and in this video I'll be going to explain you assembler directives of 80086.
00:13
Speaker A
My dear students before you learn this topic you must have this question. Why should we study assembler directive? My dear students, you should know whenever you want to do programming with any microcontroller or any microprocessor at the time. First of all, you will have to
00:33
Speaker A
learn assembler directive. Why? The reason is in assembly language programming we write program in assembler.
00:43
Speaker A
So to write program in assembler you must understand first the basic syntaxes of assembler. Why the reason is what is the job of assembler? Assembler will convert assembly language program into machine code.
01:01
Speaker A
Now there are some basic syntaxes that is there with assembler that you will have to follow for programming. So that's why you will have to learn assembler directives of 80086 for the programming of 80086.
01:19
Speaker A
You may be having knowledge of instructions of 80086 but you cannot write program as if you don't know assembler directives. So first of all you should learn all these assembler directives which I'm going to explain you in this video. After that you can
01:33
Speaker A
initiate with programming. Right? So let us see all those things step by step. So my dear students let us discuss about basics of assembler directives. So you should know my dear students assembler directives that is also referred as sudo
01:48
Speaker A
op codes. Why it is referred as sudo op codes. The reason is my dear students this directives are not instructions. M you can execute instructions only. This directives cannot be executed. These directives are used by assembler to convert program into machine code. So
02:09
Speaker A
these are the syntaxes which is there with assembler directives that you will have to learn to write program. Right?
02:17
Speaker A
So once you understand syntaxes, assembler will convert your program into machine code. Right? So here by having assembler directives you can understand how to define integer, how to define character, how to define string, how to define segments. So everything that I'm
02:35
Speaker A
going to explain you in this video step by step. So let us try to understand first how we can define segments. So my dear students when you want to define segment first of all you'll have to write label. After that write segment
02:51
Speaker A
and at last again label and ends. So here name is label and by this red color we have assembler directives.
03:02
Speaker A
So here we have defined segment with name. Right? So label of segment is n e.
03:11
Speaker A
My dear students here as if you write name as data then segment's name will be data. It doesn't mean it will be data segment segment's name is data. How to define data segment code segment. For that you'll have to learn few other
03:30
Speaker A
directives. Right? So to define segment you just need to write label first and then space segment and at last you'll have to write label then space ends right now when you write end at that time what you'll be doing is you will be
03:47
Speaker A
completing your program right so end is assembler directive which is used to end the program here once you execute and after that whatever you are writing in assembler it will not be considered as any assembly code. Right? So for
04:06
Speaker A
keyynotes you will be using this end. So after end you can write keyynotes in assembler. Right? You can say commands.
04:15
Speaker A
So after end you can write long commands even right it won't matter it will not get assembled. Now my dear students how we can assign data segment code segment.
04:28
Speaker A
For that you should know how assume directive is there. So you see here I have mentioned data segment and then data ends. So here I have defined one segment which is having label data and you see here I have written code segment
04:47
Speaker A
and code ends. So here another segment is there which is having label code. So when you write assume space CS colon code what will happen is this segment is defined as code segment of 80086 and when you write DS colon space this
05:07
Speaker A
label data. So now this segment is considered as data segment of 80086. So you must know my dear students with 80086 we have total four segments data segment code segment extra segment and stack segment right and here we are
05:25
Speaker A
defining data and code segment right as per this here if you have d space segment and at end d space ends is there and if you write ds colon d then that segment with name d you will be having
05:40
Speaker A
data segment Right? And my dear students, this assume directive that is used to define segments only. Right? So here CS means code segment of 80086 and DS means data segment of 80086. And whatever label that we write over here
05:58
Speaker A
that will mention that now this will be the authorized segment which will be code segment and this will be authorized segment that will be data segment. Now you see start and end start directive is there. So start directive that we use to
06:15
Speaker A
initiate assembly language programming. So after that you can write assembly code right and end start that will be used to end the assembly code. So you see here once you write start colon after that you can initiate with your assembly code and
06:36
Speaker A
here you see end start is written what it indicates it indicates here our assembly code is completed right now my dear students let us try to understand procedure so for procedure assembler directives are P R O C and to end the procedure you'll
06:56
Speaker A
have to Write E N D P. So this is for procedure. Why we use procedure?
07:03
Speaker A
Procedure is used to execute functions. So how we will be executing functions. You see P R O C and E N DP. So here you are initiating procedure and here we are ending the procedure and label that we
07:20
Speaker A
are writing after P O and label that we are writing after B. Here you can write any function by programming of 80086. We can write any function over here. Now with the procedure all we can do is we
07:35
Speaker A
can execute function anytime. You don't need to write function again and again. By just calling this label we can be able to execute function along with procedure. You'll have to use call function. So once you write one function
07:50
Speaker A
inside by writing program if you use call this label then what we will be doing is we'll be executing this function right so here my dear students procedure is used along with call and ending will happen with endp right and
08:10
Speaker A
to call procedure we will have to use call instruction for example if you write call space this label then it will be calling this procedure. Similarly, we have macro and nm. Macro and NM that is also used to execute function. So here
08:28
Speaker A
you see we'll be writing macro space label. After that you'll be writing one function. After that when you write and m and then space label then here there is one macro or you can say one function is there.
08:42
Speaker A
Now here the basic difference in between procedure and macro is here to call procedure we'll be using call instruction but to call this macro we will be just using label inside program.
08:56
Speaker A
So here you have written label right. So inside program when you write label it will be executing this function. Now to understand exact difference in between procedure and macro I have made separate video. The reason is already this video
09:13
Speaker A
of assembly directive that will be going to a bit long right. So separate video is there for a basic difference in between procedure and macro. You just see that that will be the next video only. Now my dear students when you want
09:28
Speaker A
to execute macro you just need to write label right. So macro is just kind of function which we use it in my program using just label. Right? So here my dear students you just need to write label only while you want to execute procedure
09:46
Speaker A
at that time you'll have to write call space label. So here sub routine will happen and here you will be executing this function. Now my dear students I'll explain you DB, DW, DD, DQ, DT and EQU.
10:03
Speaker A
DB means define bite. DW means define word. DD means define double word. DQ means define quad word. DT means define 10 words and EQU that is to define constant.
10:20
Speaker A
My dear students, DB and DW that we use. Why? The reason is bite that we use with 80086 and word that we use it with 8086.
10:32
Speaker A
As 8086 is of 16 bits, we have operation with bytes and word but double word, quad word and 10 word that we don't execute with 80086 as it is of 16 bit.
10:47
Speaker A
My dear students, here you see how we have defined it in data segment. See variable A that is a label after that when you write DB space 54 hex then one variable which is there with A that we
11:02
Speaker A
have defined. If you want to define array with variable A then here comma then second data comma then third data that you need to mention and those data that should be of 8 bits only as defined by is written.
11:18
Speaker A
Now as if you want to define a variable with word then just label that variable here I have mentioned B define word after that 16 bit data is there you see if you want to define word with array
11:35
Speaker A
then here comma second data comma third data that is how you can define it over here but you see here C EQU 10 hacks that is written what it indicates it indicates that here C is constant that is 10 hex. So whenever you want to use
11:52
Speaker A
any constant in program you can define it directly over here. My dear students here A and B are variable. These values that you can change by having a programming but the value of C that will remain constant. It cannot be changed.
12:08
Speaker A
Right? So that is how constant and variables that is that can be defined and dd dqdt that we can write over here with 80086 but my dear students it is of no use as we don't have more than 16
12:23
Speaker A
bits of instructions right so dd that requires double word so for a double word you need to have 32 bits right and for quad word you need to have 64 bits as four words are there and DT is having
12:39
Speaker A
10 bytes means 80 bits right so we don't use this we use this for higherend microprocessor like 8087 or you can say 80386 80286 in which we have used this type of directives right so my dear students DB is defining bite it is of 8
13:01
Speaker A
bits DW defines what it is of 16 bits DD means double word that will be of two bits and dq defines quadward which will be of 64 bits. DT defines 10 bytes which will be having size of 80 bits and
13:19
Speaker A
EQU that is used to define constant it will be having fixed value generally we use DB and DW remember this and in array I have already told comma then second data comma then third data that you can have if you want to define array of byte
13:36
Speaker A
then you'll have to write DB if you want to define array of word you will have to write DW right and this is what we can use it 80087 with DD DQ DT and for example as if you
13:49
Speaker A
write question mark then my dear students we have defined variable but it is having garbage value that you can say my dear students whenever we write program and if you don't define variable and if you write instructions at the
14:03
Speaker A
time it will show error so whenever you use any variable first of all define it in data segment right so you can write a space db equation mark for example if you don't have value to be written with
14:16
Speaker A
a you can say question mark means garbage value is there right and once you define it by having a programming you can define value over here right but when question mark is there it will be having garbage value so with word also
14:32
Speaker A
you can write question mark right now my dear students you should know how dup is used dup means duplicate and that We use it for array defining. Like if you write a space db means define byte variable a is defined by byte. Now when
14:53
Speaker A
you write 05 then space dup and then in bracket if some value is be written what is the meaning of it? Let us try to understand that.
15:04
Speaker A
See dup in bracket whatever thing is written that is a value and this is how many times you are duplicating this value that has been indicated over here like see 05 h dup in bracket zero is written so zero
15:21
Speaker A
will get duplicated over here five times so with array a you'll be having five bytes and all five bytes are having zero value over here right sim Similarly as if you write dup in bracket 25 hex then 25 hex that will get duplicated five
15:41
Speaker A
times that you can say right. So duplicate is used to define array as well as you can say you can create duplicate values in array right and my dear students as if you want to execute aligned then you should know why
15:58
Speaker A
we are executing this. I have seen students are having confusion why we execute this aligned. If you see memory banking video of 80086 in that I have told you as if you have even memory location then by single machine cycle we
16:14
Speaker A
can execute 16 bits. If you have odd memory location then you can execute only 8 bits of data. But if you have even memory location by single machine cycle we can execute 16 bits. So while you program microprocessor 80086 at that
16:33
Speaker A
time if you write even or aligned then all you do is you will be specifying values with even memory location. How you see here what is written define word. Here I'm having array with label a.
16:49
Speaker A
Now as if I want to execute this data and as if it is aligned what will happen in single machine cycle I'll be executing this data which is there in terms of word right as if it is there at
17:04
Speaker A
odd memory location then to execute this data you'll have to execute two machine cycles with 8086 so if you align the memory location you'll be executing data faster that is why we use E1 it is not compulsory assembler directive but that is what we
17:23
Speaker A
use to increase the execution speed of 80086 my dear students here you should know even addressing that is good for 80086 right now I'll explain you byte ptr word ptr so my dear students pointer is having data type which is byte or
17:47
Speaker A
pointer is having data type that is word that we have it by having this directives like see for example in multiplication instruction if you write by ptr in bracket 2050 hex then at this location you can say we are having a
18:08
Speaker A
data which is of byte if you don't mention this then also by default it will be considering bite only But as if you want that in terms of word then you'll have to mention as per mu then space word ptr
18:27
Speaker A
in bracket address. So as if you write word ptr then it will be taking two bytes from here. One bite is there at 2055 and second bite of this word that will be there from 2056.
18:44
Speaker A
Right? So word ptr will execute instruction as per 16 bits of data from this memory location. So it is very essential when you execute mull when you execute division when you execute increment decrement at that time you should mention as if it is having word
19:06
Speaker A
ptr and as if it is having byte ptr you should mention even if you don't mention that then it will be considering bite ptr only right so byte ptr defines memory location with byte and word ptr defines memory location with word
19:24
Speaker A
ORG is used to originate given data from mentioned memory location. For example, if I write ORG space 10,00 hacks, then this data of this variable will get originated from 1,00 even in code segment as if you write ORG space some
19:42
Speaker A
memory location then at that memory location you'll be originating your code that you can say right. So it will define this variable A from location 10,00 hack offset that we use to indicate offset like you see here we have variable and
20:03
Speaker A
that variable is stored in data segment but exactly we don't know what is the memory location of this variable. So as if you want to have this memory location then you'll have to write offset space this variable. So when you execute move
20:20
Speaker A
bx comma offset space a what it does is it will be loading address of this variable a inside bx. Even if you don't want to use offset, you are having some instruction like LEA.
20:34
Speaker A
By having LEA load effective address BX comma A, you can load offset address of A inside BX. Right? But still as if you want to execute this by move instruction, you can use offset. My dear students, near and far that we use it in
20:53
Speaker A
branch instructions. Near is used for intra segment branch. Intra means in same segment as if you have call execution then you can say near branch is happening. So you will have to write near in that case and as if you want to
21:09
Speaker A
execute that with far branch then that will be inter segment branch means branch is happening in different segment right and some model directives are there in which we define size of code segment and data segment. For example, dot model space small is written for
21:29
Speaker A
data segment to be a size with lower than 64 KB or core segment with the size of lower than 64 KB. So for dot model space small will define maximum size of data segment and code segment will be
21:47
Speaker A
there with lower than 64 KB. As if you have dot model space medium then data segment will be having maximum size of 64 KB but code segment can have size greater than 64 KB as if you use dot
22:02
Speaker A
model space large in that case data and code segment is available with greater than size of 64 KB. So based on length of program you should use these models right. So I think now my dear students it is clear to you how to use this
22:17
Speaker A
directives.
Topics:8086assembler directivespseudo opcodesassembly languageASSUMESEGMENTPROCMACRODB DWEQU

Get More with the SozAI App

Transcribe recordings, audio files, and YouTube videos — with AI summaries and speaker detection. 30 minutes free.

Or transcribe another YouTube video here →