Professional Documents
Culture Documents
Credits: 4
Microprocessor Fifth Generation Pentium
Fourth Generation
During 1980s
Low power version of HMOS technology
(HCMOS)
Third Generation 32 bit processors
During 1978 Physical memory space 224 bytes = 16 Mb
HMOS technology Faster speed, Higher Virtual memory space 240 bytes = 1 Tb
packing density Floating point hardware
16 bit processors 40/ 48/ 64 pins Supports increased number of addressing
Easier to program modes
Dynamically relatable programs
Processor has multiply/ divide arithmetic Intel 80386
hardware
More powerful interrupt handling
capabilities Second Generation
Flexible I/O port addressing During 1973
NMOS technology Faster speed, Higher
Intel 8086 (16 bit processor) density, Compatible with TTL
4 / 8/ 16 bit processors 40 pins
First Generation Ability to address large memory spaces
Between 1971 – 1973 and I/O ports
PMOS technology, non compatible with TTL Greater number of levels of subroutine
4 bit processors 16 pins nesting
8 and 16 bit processors 40 pins Better interrupt handling capabilities
Due to limitations of pins, signals are 2
multiplexed Intel 8085 (8 bit processor)
Microprocessor
Functional blocks
Various conditions of the
Computational Unit;
results are stored as
performs arithmetic and Internal storage of data
status bits called flags in
logic operations
flag register
Overview
First 16- bit processor released by Addressable memory space is
INTEL in the year 1978 organized in to two banks of 512 KB
each; Even (or lower) bank and Odd (or
higher) bank. Address line A0 is used to
Originally HMOS, now manufactured select even bank and control signal
using HMOS III technique is used to access odd bank
4
8086 Microprocessor
Common signals
Address/Data bus
https://www.geeksforgeeks.org/pin-diagram-8086-microprocessor/ 5
8086 Microprocessor
Common signals
MN/ MX
MINIMUM / MAXIMUM
READY
CLK
9
8086 Microprocessor
Minimum mode signals
10
DEN
It stands for Data Enable and is available at pin 26. It is used to enable Transreceiver 8286.
The transreceiver is a device used to separate data from the address/data bus.
ALE
It stands for address enable latch and is available at pin 25. A positive pulse is generated
each time the processor begins any operation. This signal indicates the availability of a valid
address on the address/data lines.
8086 Microprocessor
Minimum mode signals
12
8086 Microprocessor
Maximum mode signals
13
8086 Microprocessor
Maximum mode signals
15
Inside The 8088/8086
• Pipelining
• Registers
Inside The 8088/8086…pipelining
• Pipelining
– Two ways to make CPU process information faster:
• Increase the working frequency – technology dependent
• Change the internal architecture of the CPU
Dedicated Adder to
generate 20 bit address
Architecture
Segment Registers >> 20
8086 Microprocessor
Bus Interface Unit (BIU)
Architecture
Segment
Registers
Architecture
Segment Code Segment Register
Registers
16-bit
CS contains the base or start of the current code segment; IP contains the distance
or offset from this address to the next instruction byte to be fetched.
BIU computes the 20-bit physical address by logically shifting the contents of CS 4-
bits to the left and then adding the 16-bit contents of IP.
That is, all instructions of a program are relative to the contents of the CS register
multiplied by 16 and then offset is added provided by the IP.
23
8086 Microprocessor
Bus Interface Unit (BIU)
Architecture
Segment Data Segment Register
Registers
16-bit
Points to the current data segment; operands for most instructions are fetched
from this segment.
The 16-bit contents of the Source Index (SI) or Destination Index (DI) or a 16-bit
displacement are used as offset for computing the 20-bit physical address.
24
8086 Microprocessor
Bus Interface Unit (BIU)
Architecture
Segment Stack Segment Register
Registers
16-bit
The 20-bit physical stack address is calculated from the Stack Segment (SS) and
the Stack Pointer (SP) for stack instructions such as PUSH and POP.
In based addressing mode, the 20-bit physical stack address is calculated from
the Stack segment (SS) and the Base Pointer (BP).
25
8086 Microprocessor
Bus Interface Unit (BIU)
Architecture
Segment
Registers
Extra Segment Register
16-bit
Points to the extra segment in which data (in excess of 64K pointed to by the
DS) is stored.
String instructions use the ES and DI to determine the 20-bit physical address
for the destination.
26
8086 Microprocessor
Bus Interface Unit (BIU)
Architecture
Segment Instruction Pointer
Registers
16-bit
27
8086 Microprocessor
Bus Interface Unit (BIU)
Instruction queue
Architecture
28
8086 Microprocessor
Execution Unit (EU)
A decoder in the EU
control system
translates instructions.
and
Some of the 16 bit registers can be
Index registers (Source used as two 8 bit registers as :
Index, Destination Index)
each of 16-bits AX can be used as AH and AL
BX can be used as BH and BL
CX can be used as CH and CL 29
DX can be used as DH and DL
8086 Microprocessor
Execution Unit (EU)
Architecture
EU Accumulator Register (AX)
Registers
30
8086 Microprocessor
Execution Unit (EU)
Architecture
EU Base Register (BX)
Registers
Consists of two 8-bit registers BL and BH, which can be
combined together and used as a 16-bit register BX.
31
8086 Microprocessor
Execution Unit (EU)
Architecture
EU Counter Register (CX)
Registers
Consists of two 8-bit registers CL and CH, which can be
combined together and used as a 16-bit register CX.
Example:
32
8086 Microprocessor
Execution Unit (EU)
Architecture
EU
Registers
33
8086 Microprocessor
Execution Unit (EU)
Architecture
EU Stack Pointer (SP) and Base Pointer (BP)
Registers
SP and BP are used to access data in the stack segment.
34
8086 Microprocessor
Execution Unit (EU)
Architecture
EU Source Index (SI) and Destination Index (DI)
Registers
Used in indexed addressing.
35
8086 Microprocessor
Architecture Execution Unit (EU)
Auxiliary Carry Flag
Carry Flag
Flag Register This is set, if there is a carry from the
This flag is set, when there is
lowest nibble, i.e, bit three during
addition, or borrow for the lowest a carry out of MSB in case of
nibble, i.e, bit three, during addition or a borrow in case
subtraction. of subtraction.
This flag is set, when the This flag is set, if the result of This flag is set to 1, if the lower
result of any computation the computation or comparison byte of the result contains even
is negative performed by an instruction is number of 1’s ; for odd number
zero of 1’s set to zero.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF DF IF TF SF ZF AF PF CF
Tarp Flag
Over flow Flag If this flag is set, the processor
This flag is set, if an overflow occurs, i.e, if the result of a signed enters the single step execution
operation is large enough to accommodate in a destination
mode by generating internal
register. The result is of more than 7-bits in size in case of 8-bit
signed operation and more than 15-bits in size in case of 16-bit interrupts after the execution of
sign operations, then the overflow will be set. each instruction
8086 registers
categorized 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
into 4 groups OF DF IF TF SF ZF AF PF CF
AX 16-bit Accumulator Stores the 16-bit results of arithmetic and logic operations
AL 8-bit Accumulator Stores the 8-bit results of arithmetic and logic operations
BX Base register Used to hold base value in base addressing mode to access memory
data
CX Count Register Used to hold the count value in SHIFT, ROTATE and LOOP instructions
DX Data Register Used to hold data for multiplication and division operations
SP Stack Pointer Used to hold the offset address of top stack memory
BP Base Pointer Used to hold the base value in base addressing using SS register to
access data from stack memory
SI Source Index Used to hold index value of source operand (data) for string
instructions
DI Data Index Used to hold the index value of destination operand (data) for string
operations
38
8086 Microprocessor
Addressing Modes
Every instruction of a program has to operate on a data.
The different ways in which a source operand is denoted
in an instruction are known as addressing modes.
1. Register Addressing
Group I : Addressing modes for register and
2. Immediate Addressing immediate data
3. Direct Addressing
5. Based Addressing
Group II : Addressing modes for memory data
6. Indexed Addressing
8. String Addressing
Addressing Modes
immediate data
8. String Addressing
40
8086 Microprocessor Group I : Addressing modes for register and
Addressing Modes
immediate data
1. Register Addressing
In immediate addressing mode, an 8-bit or 16-bit
2. Immediate Addressing data is specified as part of the instruction
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DL, 08H
5. Based Addressing
The 8-bit data (08H) given in the instruction is
6. Indexed Addressing moved to DL
8. String Addressing
10. Indirect I/O port Addressing The 16-bit data (0A9FH) given in the instruction is
moved to AX register
11. Relative Addressing
(AX) 0A9FH
12. Implied Addressing
41
8086 Microprocessor
12. Implied Addressing This addressing mode is called direct because the
displacement of the operand from the segment
base is specified directly in the instruction.
45
8086 Microprocessor Group II : Addressing modes for memory
(CL) (MA)
(CH) (MA +1)
46
8086 Microprocessor Group II : Addressing modes for memory
Addressing Modes
In Based Addressing, BX or BP is used to hold the
data
1. Register Addressing
base value for effective address and a signed 8-bit
2. Immediate Addressing or unsigned 16-bit displacement will be specified
in the instruction.
3. Direct Addressing
In case of 8-bit displacement, it is sign extended
4. Register Indirect Addressing to 16-bit before adding to the base value.
(AL) (MA) 47
(AH) (MA + 1)
8086 Microprocessor
Addressing Modes
Group II : Addressing modes for memory
data
(CL) (MA)
(CH) (MA + 1)
48
8086 Microprocessor Group II : Addressing modes for memory
Addressing Modes
In Based Index Addressing, the effective address
data
1. Register Addressing
is computed from the sum of a base register (BX
2. Immediate Addressing or BP), an index register (SI or DI) and a
displacement.
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DX, [BX + SI + 0AH]
5. Based Addressing
Operations:
6. Indexed Addressing
000AH 0AH (Sign extended)
7. Based Index Addressing
49
8086 Microprocessor Group II : Addressing modes for memory
1. Register Addressing
Addressing Modes Employed in string operations to operate on string
data
data.
2. Immediate Addressing
The effective address (EA) of source data is stored
3. Direct Addressing in SI register and the EA of destination is stored
in DI register.
4. Register Indirect Addressing
Segment register for calculating base address of
5. Based Addressing source data is DS and that of the destination data
is ES
6. Indexed Addressing
1. Register Addressing
Addressing Modes
2. Immediate Addressing
3. Direct Addressing
5. Based Addressing
6. Indexed Addressing
Instructions using this mode have no operands.
The instruction itself will specify the data to be
7. Based Index Addressing
operated by the instruction.
8. String Addressing
Example: CLC
9. Direct I/O port Addressing
This clears the carry flag to zero.
10. Indirect I/O port Addressing
53
8086 Microprocessor
Instruction Set
8086 supports 6 types of instructions.
2. Arithmetic Instructions
3. Logical Instructions
https://www.tutorialspoint.com/assembly_programming/assembly_logical_instructions.htm
54
8086 Microprocessor
Instruction Set
1. Data Transfer Instructions
Generally involve two operands: Source operand and Destination operand of the
same size.
A 8-bit data can only be moved to 8-bit register/ memory and a 16-bit data can be
moved to 16-bit register/ memory.
55
Instruction Set
8086 Microprocessor
56
8086 Microprocessor
Instruction Set
1. Data Transfer Instructions
PUSH mem
(SP) (SP) – 2
MA S = (SS) x 1610 + SP
(MA S ; MA S + 1) (mem)
POP mem
MA S = (SS) x 1610 + SP
(mem) (MA S ; MA S + 1)
(SP) (SP) + 2
57
Instruction Set
8086 Microprocessor
58
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
ADD A, data
59
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
ADD A, data
60
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
SUB A, data
61
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
SBB A, data
62
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
63
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
64
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
65
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
66
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
67
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
68
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
CMP A, data
69
8086 Microprocessor
Instruction Set
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL … ROR, ROL
70
8086 Microprocessor
Instruction Set
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL … ROR, ROL
71
Instruction Set
8086 Microprocessor
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL … ROR, ROL
72
Instruction Set
8086 Microprocessor
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL … ROR, ROL
The TEST instruction
works same as the AND
operation, but unlike
AND instruction, it does
not change the first
operand. So, if we need
to check whether a
number in a register is
even or odd, we can also
do this using the TEST
instruction without
changing the original
number.
73
8086 Microprocessor
Instruction Set
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL … ROR, ROL
74
8086 Microprocessor
Instruction Set
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL … ROR, ROL
75
8086 Microprocessor
Instruction Set
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL … ROR, ROL
76
8086 Microprocessor
Instruction Set
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL … ROR, ROL
77
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
8086 instruction set includes instruction for string movement, comparison, scan, load and store.
String instructions end with S or SB or SW. S represents string, SB string byte and SW string word.
Offset or effective address of the source operand is stored in SI register and that of the destination
operand is stored in DI register.
78
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
REPNZ/ REPNE
Result should not be zero for condition true
(Repeat CMPS or SCAS until ZF = 1) While CX 0 and ZF = 0, repeat execution of string instruction
and
(CX) (CX) - 1
Note: Always ‘REPZ’ instruction can be used in association with the string related
operations.
79
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
MOVS
(MAE) (MA)
80
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
CMPS
81
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
Scan (compare) a string byte or word with accumulator
SCAS
LODS
LODSW
MA = (DS) x 1610 + (SI)
(AX) (MA ; MA + 1)
83
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
STOS
84
8086 Microprocessor
Instruction Set
5. Processor Control Instructions
Mnemonics Explanation
STC Set CF 1
CLC Clear CF 0
CMC Complement carry CF CF/
STD Set direction flag DF 1
CLD Clear direction flag DF 0
STI Set interrupt enable flag IF 1
CLI Clear interrupt enable flag IF 0
NOP No operation
ESC opcode mem/ reg Used to pass instruction to a coprocessor which shares the
address and data bus with the 8086
LOCK Lock bus during next instruction
85
8086 Microprocessor
Instruction Set
6. Control Transfer Instructions
Mnemonics Explanation
CALL reg/ mem/ disp16 Call subroutine
86
8086 Microprocessor
Instruction Set
6. Control Transfer Instructions
8086 signed conditional branch 8086 unsigned conditional branch
instructions instructions
Checks flags
87
8086 Microprocessor
Instruction Set
6. Control Transfer Instructions
8086 signed conditional branch 8086 unsigned conditional branch
instructions instructions
Note: Before these instructions comparison instruction is to be used for comparing two operands. 88
8086 Microprocessor
Instruction Set
6. Control Transfer Instructions
Mnemonics Explanation
JC disp8 Jump if CF = 1
JP disp8 Jump if PF = 1
JO disp8 Jump if OF = 1
JS disp8 Jump if SF = 1
89
Iteration Control Instructions
These instructions are used to execute the given instructions for number of times.
Following is the list of instructions under this group −
LOOP − Used to loop a group of instructions until the condition satisfies, i.e., CX = 0
Assemble Directives
Instructions to the Assembler regarding the program being executed.
Control the generation of machine codes and organization of the program; but no
machine codes are generated for assembler directives.
Used to :
› specify the start and end of a program
› attach value to variables
› allocate storage locations to input/ output data
› define start and end of segments, procedures, macros etc..
91
8086 Microprocessor
DB
Assemble Directives
Define Byte
ASSUME Range : 00H – FFH for unsigned value; 00H – 7FH for
positive value and 80H – FFH for negative value
ORG
END
EVEN General form : variable DB value/ values
EQU
PROC
FAR Example:
NEAR
LIST DB 7FH, 42H, 35H
ENDP
Three consecutive memory locations are reserved for the variable LIST
SHORT and each data specified in the instruction are stored as initial value in
the reserved memory location
MACRO
ENDM 92
8086 Microprocessor
DB
Assemble Directives
Define Word
PROC
FAR Example:
NEAR
ALIST DW 6512H, 0F251H, 0CDE2H
ENDP
Six consecutive memory locations are reserved for the variable ALIST
SHORT and each 16-bit data specified in the instruction is stored in two
consecutive memory location.
MACRO
ENDM 93
8086 Microprocessor
DB
Assemble Directives
SEGMENT : Used to indicate the beginning of a code/ data/
stack segment
DW
ENDS : Used to indicate the end of a code/ data/ stack
SEGMENT segment
ENDS
General form:
ASSUME
ORG
END Segnam SEGMENT
EVEN …
… Program code
EQU … or
… Data Defining Statements
…
PROC …
FAR
Segnam ENDS
NEAR
ENDP
SHORT
DB
Assemble Directives
Informs the assembler the name of the program/ data
segment that should be used for a specific segment.
DW
General form:
SEGMENT
ENDS
ASSUME segreg : segnam, .. , segreg : segnam
ASSUME
ORG
User defined name of the
END Segment Register
segment
EVEN
EQU
PROC Example:
FAR
NEAR ASSUME CS: ACODE, DS:ADATA Tells the compiler that the instructions of the
program are stored in the segment ACODE and
ENDP data are stored in the segment ADATA
SHORT
MACRO
ENDM 95
Assemble Directives
8086 Microprocessor
ORG
Examples:
END
EVEN ORG 1000H Informs the assembler that the statements following ORG
1000H should be stored in memory starting with effective
EQU address 1000H
PROC
FAR LOOP EQU 10FEH Value of variable LOOP is 10FE H
NEAR
ENDP
_SDATA SEGMENT In this data segment, effective address of memory location
ORG 1200H assigned to A will be 1200 H and that of B will be 1202 H and
SHORT A DB 4CH 1203H.
EVEN
B DW 1052H
MACRO _SDATA ENDS
ENDM 96
LENGTH: LENGTH is an operator, which tells the assembler to determine the number of
elements in some named data item, such as a string or an array. When the assembler reads
the statement MOV CX, LENGTH STRING1, for example, will determine the number of
elements in STRING1 and load it into CX. If the string was declared as a string of bytes,
LENGTH will produce the number of bytes in the string. If the string was declared as a word
string, LENGTH will produce the number of words in the string.
LENGTH: Byte length of a label: This is used to refer to the length of a data array or a
string. Ex : MOV CX, LENGTH ARRAY
OFFSET: offset of a label: When the assembler comes across the OFFSET operator along
with a label, it first computing the 16-bit offset address of a particular label and replace
the string ‘OFFSET LABEL’ by the computed offset address. Ex : MOV SI, offset list
Assemble Directives
PROC Indicates the beginning of a procedure
DB
ENDP End of procedure
DW
FAR Intersegment call
SEGMENT
ENDS NEAR Intrasegment call
General form
ASSUME
DB
Assemble Directives
Examples:
DW
SEGMENT ADD64 PROC NEAR The subroutine/ procedure named ADD64 is declared as
NEAR and so the assembler will code the CALL and RET
ENDS … instructions involved in this procedure as near call and
… return
…
ASSUME
RET
ADD64 ENDP
ORG
END
EVEN
EQU CONVERT PROC FAR The subroutine/ procedure named CONVERT is declared as
FAR and so the assembler will code the CALL and RET
… instructions involved in this procedure as far call and return
…
PROC …
ENDP
RET
FAR CONVERT ENDP
NEAR
SHORT
MACRO
ENDM 99
8086 Microprocessor
Assemble Directives
DB Reserves one memory location for 8-bit signed displacement
in jump instructions
DW
Example:
SEGMENT
ENDS
ASSUME JMP SHORT AHEAD The directive will reserve one memory location
for 8-bit displacement named AHEAD
ORG
END
EVEN
EQU
PROC
ENDP
FAR
NEAR
SHORT
MACRO
ENDM 100
8086 Microprocessor
Assemble Directives
DB MACRO Indicate the beginning of a macro
PROC
ENDP
FAR
NEAR User defined name of the macro
SHORT
MACRO
ENDM 101
Procedures and Macros:
http://
www.snjb.org/polytechnic/up-images/downloads/chapter%206-MAPupFile_058d4f
a990abaa.pdf
Define procedure : A procedure is group of instructions that usually performs one task. It is a
.reusable section of a software program which is stored in memory once but can be used as
often as necessary. A procedure can be of two types. 1) Near Procedure 2) Far Procedure
Near Procedure: A procedure is known as NEAR procedure if is written(defined) in the same
code segment which is calling that procedure. Only Instruction Pointer(IP register) contents
will be changed in NEAR procedure. FAR procedure : A procedure is known as FAR procedure
if it is written (defined) in the different code segment than the calling segment. In this case
both Instruction Pointer (IP) and the Code Segment (CS) register content will be changed.
Directives used for procedure : PROC directive: The PROC directive is used to identify the
start of a procedure. The PROC directive follows a name given to the procedure. After that
the term FAR and NEAR is used to specify the type of the procedure. ENDP Directive: This
directive is used along with the name of the procedure to indicate the end of a procedure to
the assembler. The PROC and ENDP directive are used to bracket a procedure.
CALL instruction and RET instruction :
There are two types of calls. 1)Near Call or Intra segment call. 2) Far call or Inter Segment call
Operation for Near Call : When 8086 executes a near CALL instruction, it decrements the
stack pointer by 2 and copies the IP register contents on to the stack. Then it copies address
of first instruction of called procedure.
Operation for Near Call : When 8086 executes a near CALL instruction, it decrements the
stack pointer by 2 and copies the IP register contents on to the stack. Then it copies address
of first instruction of called procedure.
Operation of FAR CALL: When 8086 executes a far call, it decrements the stack pointer by 2
and copies the contents of CS register to the stack. It the decrements the stack pointer by 2
again and copies the content of IP register to the stack. Finally it loads CS register with base
address of segment having procedure and IP with address of first instruction in procedure.
ASSUME CS:CODE, DS:DATA, SS:STACK_SEG CALL SUBTRACTION
MOV AH, 4CH
DATA SEGMENT INT 21H
NUM1 DB 50H Procedure Example
NUM2 DB 20H ADDITION PROC NEAR
ADD_RES DB ?
program: MOV AL, NUM1
SUB_RES DB ? MOV BL, NUM2
DATA ENDS ADD AL, BL
MOV ADD_RES, AL
STACK_SEG SEGMENT RET
ADDITION ENDP
DW 40 DUP(0) ; stack of 40 words, all initialized to zero
TOS LABEL WORD SUBTRACTION PROC
STACK_SEG ENDS MOV AL, NUM1
MOV BL, NUM2
CODE SEGMENT SUB AL, BL
MOV SUB_RES, AL
START: MOV AX, DATA ; initialize data segment RET
MOV DS, AX SUBTRACTION ENDP
MOV AX, STACK_SEG ; initialize stack segment
MOV SS, AX CODE ENDS
MOV SP, OFFSET TOS ; initialize stack pointer to TOS END START
CALL ADDITION
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
NUM1 DW 1000H
NUM2 DW 2000H
RES DW ?
DATA ENDS MACRO program
CODE SEGMENT Example
ADDITION MACRO NO1, NO2, RESULT
MOV AX, NO1
MOV BX, NO2
ADD AX, BX
MOV RESULT, AX
ENDM
START: MOV AX, DATA ; initialize data segment
MOV DS, AX
ADDITION NUM1, NUM2, RES
MOV AH, 4CH
INT 21H
CODE ENDS
END START
Modular programming: https
://en.wikipedia.org/wiki/Modular_programming.
Modular programming is a software design technique that emphasizes separating the
functionality of a program into independent, interchangeable modules, such that each
contains everything necessary to execute only one aspect of the desired functionality.
A module interface expresses the elements that are provided and required by the module.
The elements defined in the interface are detectable by other modules. The implementation
contains the working code that corresponds to the elements declared in the interface.
Modular programming is closely related to structured programming and
object-oriented programming, all having the same goal of facilitating construction of large
software programs and systems by decomposition into smaller pieces, and all originating
around the 1960s. While the historical usage of these terms has been inconsistent, "modular
programming" now refers to high-level decomposition of the code of an entire program into
pieces: structured programming to the low-level code use of structured control flow, and
object-oriented programming to the data use of objects, a kind of data structure.
107
Linking and relocation:
In computing, a linker or link editor is a computer utility program that takes one or more
object files generated by a compiler and combines them into a single executable file, library
file, or another 'object' file.
Executes ISR
0007C
H (27)
Type 05H Interrupt (Reserved)
0001 4
Type 04H Interrupt (Over Flow)
H
Type 03H Interrupt (Break Point)
00010H Type 02H Interrupt (NMI)
0004F
0000C Type 01H Interrupt Dedicated
H
H (Trap or Single step) Interrupts
(05
CS 0003FH
00008H
00002H
C Interrupt
Type 00H )
IP 00001 S by Zero)
(Divide
H
00000H
I
P
https://www.eeeguide.com/8086-interrupt/
Interrupt Vector Table
2 bytes 00002H
CS LSB CS 00003H
CS MSB Type 0 or
IP 00001H
2 bytes 00000H INT 00 Interrupt
IP LSB IP MSB
CS LSB MSB
Offset = 02 x 4 = 08
= 00008H
256 Interrupts of 8086 are Divided into 3 Groups
1. Type 00 to Type 04 interrupts -
These are used for fixed operations and hence are
called dedicated interrupts