UNIT-1 Assembly Language Programming
UNIT-1 Assembly Language Programming
MICROPROCESSOR
ARCHITECTURE
Structure
Page No.
Introduction
Objectives
Microcomputer Architecture
Structure of 8086 CPU
1.3.1 The Bus Interface Unit
1.3.2 Execut~onUnit (EU)
Register Set of 8086
Instruction Set of 8086
1.5.1 Data Transfer Instructions
1S.2 Arithmetic Instructions
1 S.3
Bit Manipulation Instructions
1 S.4 Program Execution Transfer Instructions
1 S.5 String Instructions .
1.5.6 Processor Control lnsthctions
Addressing Modes
1.6.1 Reg~sterAddressing Mode
1.6 2 Immediate Addressing Modc
1.6.3 Direct Addressing Modc
1.6.4 Indirect Address~ngMode
Summary
Solutions/Answers
1.O
INTRODUCTION
In the previous blocks of this course, we have discussed concepts relating to CPU
organization, register set. ~nstructionset, addressing modes with a few examples. Let
us look at one micropmccssor architecture in regard of all the above concepts. We
have selected one of the sl~nplestprocessors 8086, for this purpose. Although the
131-ocessortechnology is old, all the concepts are valid for higher end Intel processor.
'Therefore, in this unit. w will discuss the 8086 microprocessor in some detail.
We have started the discbPb~onof the basic microcomputer architecture. This
discussion is followed b u 'lhe details on the components of CPU of the 8086
microprocessor. Then \\ s.hLve discussed the register organization for this processor.
We have also discussed t i i t ~atructionset and addressing modes for this procFssor.
Thus, this unit presents e\liabf*~.rr\.c
details of the 8086 microprocessor. These details
will then be used in Assembl), 1'1 ogramming.
1.l OBJECTIVES
.I
Assembly Language
Programming
Data bus
Input Device
I10 Ports
Control
CPU
Control
Memory
Bus (RAM & ROM)
Output Device
Address bus
Figure 1: Components of a Microcomputer
Bus Sizes
1. The Address bus: 8085 microprocessor has 16 bit lines. Thus, it can access up to
216 = 64K Bytes. The address bus of 8086 microprocessor has a 20 bits address
bps. Thus it can access upto 2" = 1M Byte size of RAM directly.
2. Data bus is the number of bits that can be transferred simultaneousli It is 16 bits
in 8086.
I
Microprocessors
The microprocessor is a complete CPU on a single chip. The main advantages of the
microprocessor are:
compact but powerll;
oan be microprogrammed for user's needs;
easily programmable and maintainable due to small size; and
useful in distributed applications.
A microprocessor must demonstrate:
More throughput
More addressing capability
Powerful addressing modes
Powerful instruction set
Faster operation through pipelining
Virtual memory management.
However, RISC machine do not agree with above principles.
Microprocessor
Architecture
The assembly language for more advanced chips subsumes the simplest 8086/ 8088
asselnbly language. Therefore, we will confine our discussions to Intel 8086/8088
asse~nblylanguage. You must refer to the further readings for more details on
asselnbly language of Pentium, G4 and other processors.
All lnicroprocessors execute a continuous loop of fetch and execute cycles.
while (1)
fetch (instruction); ,
execute (using date);
i
1.3
-
a
I
'
2.
8
I
a
8
8
8
a
I
a
I
8'
...*-......*.-..,
8
8
8
..-......
- .
.-
.-%
Assembly Language
Programming
The word independent implies that these two units can function parallel to each other.
In other words they may be considered as two stages of the instruction pipeline.
1
The instruction1data is then passed to the execution unit. This BIU consists of
(a)
lI
The instruction queue is used to store the instruction "bytes" fetched. Please
note two points here: that it is (1) A Byte (2) Queue. This is used to store
information in byte form, with the underlying queue data structure. The
advantage of this queue would only be if the next expected instructions are
fetched in advance, thus, allowing a pipeline of fetch and execute cycles.
(b)
These are very important registers of the CPU. Why? We will answer this later.
In 8086 microprocessor, the memory is a byte organized, that is a memory
address is byte address. However, the number of bits fetched is 16 at a time. The
segment registers are used to calculate the address of memory location along
with other registers. A segment register is 16 bits long.
The BIU contains four sixteen-bit registers, viz., the CS: Code Segment, the DS:
Data Segment, the SS: Stack Segment, and the ES: Extra Segment. But what is
the need of the segments: Segments logically divide a program into logical
entities of Code, Data and Stack each having a specific size of 64 K. The
segment register holds the upper 16 bits of the starting address of a logical
group of memory, called the segment. But what are the advantages of using
segments? The main advantages of using segments are:
Logical division of program, thus enhancing the overall possible memory
use and minimise wastage.
The addresses that need to be used,in programs are relocatable as they are
the offsets. Thus, the segmentation supports relocatability.
Although the size of address, is 20 bits, yet only the maximum segment
size, that is 16 bits, needs to be kept in instruction, thus, reducing
instruction length.
I
1
H-
m n
Microprocessor
Architecture
of extra segment
60000h
448AOh
64K
300qOh
--L
Although the size of each segment can be 64K, as they are overlapping segments we
can create variable sizeof'segments, with maximum as 64K. Each segment has a
specific function. 8086 supports the following segments:
As per model of assembly program, it can have more than one of any type of
segments. However,.at a time only four segments one of each type, can be active.
Assembly Language
Programming
range from OOOOh to FFFFh. But, how will the segment address and offset be added to
calculate physical address? Let us explain using the following examples:
-Implied zero
6 0 0 1 0
Physical Address
Example 2
= 0020h
The offset of the data byte
The value of the data segment register (DS) = 3000h
Physical address of the data byte
-
- Implied Zero
DS
Offset
Physical Address
3 0
Example 3
The value of the Instruction Pointer, holding address of the instruction = 1234h
The value of the code segment register (CS) = 448Ah
Physical address of the instruction
Physical Address
5 A 0 4
Instruction Pointer
The instruction pointer points to the offset of the current instruction in the code
segment. It is used for calculating the address of instruction as shown above.
Microprocessor
Architecture
Execution unit performs all the ALU operations. The execution unit of 8086 is of 16
bits. It also contains the control unit, which instructs bus interface unit about which
memory location to access, and what to do with the data. Control unit also performs
decoding and execution of the instructions. The EU consists of the following:
(a)!
Registers
All CPUs have a defined number of opera' :anal registers. 8086 has several general
purpose and special purpose registers. We ill discuss these registers in the following
sections.
-1.4
The 8086 registers have five groups of registers. These groupings are done on the
basis of the main functions of the registers. These groups are:
8086 microprocessors have four general purpose registers namely, AX, BX, CX, DX.
All these registers are 16 - bit registers. However, each register can be used as two
g,eneral-purposebyte registers also. These byte registers are named AH and AL for
AX,BH and BL for BX, CH and CL for CX, and DH and DL for DX. The H in
register name represents higher byte while L represents lower byte of the 16 bits
registers. These registers are primarily used for general computation purposes.
Ilowever, in certain instruction executions they acquire a special meaning.
,4X register is also known as accumulator. Some of the instructions like divide, rotate,
shift etc. require one of the operands to be available in the accumulator. Thus, in such
~nstructions,the value of AX should be suitably set prior to the instruction.
rn
BX register is mainly used as a base register. It contains the starting base location of a
memory region within a data segment.
CX register is a defined counter. It is used in loop instruction to store loop counter.
DX register is used to contain I10 port address for 110 instruction.
You will experience their usage in various assembly programs discussed later.
Segment Registers
Segment Registers are used for calculating the physical address of the instruction or
memory. Segment registers cannot be used as byte registers.
Pointer and Index Registers
The 8086 microprocessor has three pointer and index registers. Each of these registers
is of 16 bit and cannot be accessed byte wise. These are Base Pointer (BP), Source
Index (Sl) and Destination Index (DI). Although they can be used as general purpose
registers, their main objective is to contain indexes. BP is used in stack segment, SI in
Data segment and DI in Extra Data segment.
11
Assembly Language
Programming
Special Registers
-4 Last in First Out (LIFO) stack is a data structure used for parameter passing, return
adckess storage etc. 8086 stack is 64K bytes Base of the stack is pointed to by the
stack segment (SS) register while the offset or top of the stack is stored in Stack
Pointer (SP) register. Please note that although the memory in 8086 has byte
addresses, stack is a word stack, which is any push operation will occupy two bytes.
Flags Register
A flag represents a condition code that is 0 or 1. Thus, it can be represented using a
flip- flop. 8086 employs a 16-bit flag register containing nine flags. The following
table shows the flags of 8086.
Conditional flags are set by some condition generated as a result of the last
-- CF
PF
Carry Flag
Parity Flag
Auxiliary F&
--
Interrupt Enable
What is the purpose of the queue in the bus interface unit of 8086
. microprocessors?
................................................................................................
................................................................................................
................................................................................................
2.
Find out the physicil addresses for the following segment register: offset
(a) SS:SP = 0100h:0020h
(b) DS:BX = 0200h:0100h
(a)
(b)
(c)
The Source Index (SI) and Destination Index(D1) registeis in 8086 can also be
used as general registers.
(d)
1.5
-
Afler discussing the basic organization of the 8086 micro-processor, let us now
provide an overview of various instructions available in the 8086 microprocessor. The
instruction set is presented in the tabular form. An assembly language instruction in
the 8086 includes the following:
Label: Op-code
Operand@); Comment
For example, to add the content of AL and BL registers to get the result in AL, we use
the following assembly instruction.
NEXT: ADD
AL,BL
;ALeAL+BL
Please note that NEXT is the label field. It is giving an identity to the statement. It is
an optional field, and is used when an instruction is to be executed again through a
L.OOP or GO TO. ADD is symbol~cop-code, for addition operation. AL and BL are
the two operands of the instructions. Please note that the number of operands is
c~ependentupon the instructions. 8086 instructions can have zero, one or two
operands. An operand in 8086 can be:
1.
2.
3.
4.
A register .
A memory location
Microprocessor
Architecture
Assembly Langaage
Programming
PUSH operand
PUSH BX
; decrement stack polnter
;by; two, and copy BX to
;stack.
; decrement stack pointer
;by two, and copy
; BX to stack
POP AX
; Copy content for top
; of stack to AX.
XCHG DX,AX
; Exchange word in DX
;with word in AX
Example 1s available In
Unit 3.
IN AL,028h
; read a byte from port
; 028h to AL register
loads the
LDS des-reg
LES des-reg
LAHF
SAHF
PUSHF
i 'OpF
--t
INC des
DESCRIPTION
Adds byte to byte, or word to word.
The source may be an immediate
operand, a register or a memory
location. The rules for operands are
the same as that of MOV instruction.
To add a byte to a word, first copy the
byte to a word location, then fill up
the upper byte of the word with zeros.
This instruction effects the following
flags: AF, CF, OF, PF, SF. ZF.
Add byte + byte + carry flag, or word
+ word + carry flag. It adds the two
operands with the carry flag. Rest all
the details are the same as that of
( ADD instruction.
I It increments svecified bvte or word
operand by one. The ope;and can be a
register or a memory location. It can
effect AF, SF, ZF, PF, and OF flags.
It does not affect the carry flag, that
is, if you increment a byte operand
EXAMPLE
ADD AL,74H
;Add the number 74H to
; AL register, and store the
;result back in AL
ADD DX,BX
;Add the contents of DX to
; BX and store the result in ;
DX, BX remains
; unaffected.
1 INC
BX
INC BL
';,Add 1 to the contents of
;BL register
Microprocessor
Architecture
Assembly Language
Programming
AAA
DAA
DEC src
NEG src
ADD AL,BL
;AL=00 1 10101, ASCII 05
; BL=00 1 11001, ASCII 09
; after addition
;AL = 01 101110, that is,
; 6EH- incorrect
;temporary result
AAA
;AL = 00000 100.
;Unpacked BCD for 04
; carry = 1, indicates
; the result is 14
; AL = 0 101 1001 (59
; BCD)
; BL = 001 1 0101 (35
; BCD)
ADD AL, BL
; AL = 10001101 or
;8Eh (incorrect BCD)
DAA
; AL = 1001 0100
;E 94 BCD : Correct.
Subtract byte from byte, or word from SUB AX, 3427h
word. (des f des - src). For
; Subtract 342% from AX
subtraction the carry flag r'unctions as ;register, and store the
a borrow flag, that is, if the number in ;result back in AX
the source is greater than the number
in the destination, the borrow flag is
to set 1. Other details are equivalent
to that of the ADD instruction.
Subtract operands involving previous SBB AL,CH
carry if any. The instruction is similar ; subtract the contents
to SUB, except that it allows us to
;of CH and CF from AL
subtract two multibyte numbers,
; and store the result
because any borrow produced by
; back in AL.
subtracting less-significant byte can
be included in the result using this
instruction.
Decrement specified byte or specified DEC BP
word by one. Rules regarding the
; Decrement the contents
operands and the flags that are
; of BP
affected are same as INC instruction. ;register by one.
Please note that if the contents of the
operand is equal to zero then after
decrementing the contents it bedomes
OFFH or OFFFFH, as the case may be.
The catry flag in this case is not
affected.
Negate - creates 2's complement of a
NEG AL
given number, this changes the sign
; Replace the number in
; AL with it's 2's
of-a number. However, please note
that if you apply this instruction on
;complement
operand having value -128 (byte
operand) or -32768 iword operand) it
will result in overflow condition. The
overflow (OF) flag will be set to
SUB AL,BL
; (5-9) result:
;AL= 1111 1100 = - 4 in
; 2's complement, CF = 1
AAS ;result: - - - .
;AL=00000100=
- ; BCD 04,
;CF = 1 borrow needed.
;AL=2Fh, CF =O
DAS
;Results in AL = 29 BCD
DIV src
MUL BH
; AX=AL * BH=002Dh
AAM
;AX=00000100 00000101 ;
BCD 45 : Correct result
>
IDIV
?
A m
; AL = 11001010 = -26h =
; - 38 decimal
;CH = 0000001 1 = + 3h =
;3 decimal
; According to the operand
;rules to divide by a byte
;the number should be
; present in a word register, ;
i.e. AX. So, first convert
; the operand in AL to word
; operand. This can be done ;
by sign extending the
; AL register,
; this makes AX
; 11111111 11001010.
;(Sign extension can also
; be done with the help of
;an instruction, discussed
; later)
I D N CH
;AXICH
; A L = 11110100=-OCH;
= - 12 Decimal
; A H = 11111110=-02H=;02 Decimal
;Although the quotient is
;actually closer to -13
;(-'12.66667) than -12, but
; 8086 truncates the result
; t o give-12.
;AX= 0607 unpacked
; BCD for 6
CBW
CWD
;and 7 CH = 09h
AAD
; adjust to binary before
;division AX= 0043 =
;043h = 67 Decimal
DIV CH
;Divide AX by unpacked
; BCD in CH
; AL = 07 unpacked BCD
;AH = 04 unpacked BCD
;PF=SF=ZF=O
; AL = 1001 1011 = - 155
Fill upper-byte or word with copies
of sign bit of lower bit. This is called ; decimal AH = 00000000
sign extension of byte to word. This CBW ;convert signed
;byte in AL to signed
instruction does no1 change any
flags. This operatio11is done with AL ; word in AX = 11111111
; 10011011 = - 1% decimal
register in the result being stored in
AX.
Fill upper word or double word with ; DX : 0000 0000 0000 0000
;AX:1111000001010001
sign bit of lower word. This
CWD
instruction is an extension of the
1111 1111 1111 1111:
previous instruction. This instruction ;DX:AX=
;
0000 0101 0001
results in sign extension of AX
register to DX:AX double word.
These instructions are used at the bit level. These instructions can be used for testing a
zero bit, set or reset a bit and to shift bits across registers. Let us look into some such
' NOT
MNEMONIC
des
'
DESCRIPTION
Complements each bit to produce
1's complement of the specified
byte or word operand. The
operand can be a register or a
memory operand.
Bitwise AND of two byte or word
operands. The result is des f des
AND src. The source can be an
immediate operand a register, or a
memory operand.
destination
can be a register or a memory
operand. Both operands cannot be
memory operands at the same
time. The CF and the OF flags are
both zero after the AND
operation. PF, SF and ZF area
updated, Afis left undefined.
OR each corresponding bits of the
byte or word operands. The other
operands rules are same as AND.
des C des OR src
XOReachcorrespondingbitina
byte or word operands rules are
two same as AND and OR.
des C Des + src
ne
OR des, src
XOR des,src
EXAMPLE
; BX = 00 11 1010 000 1 0000
NOT BX
; B X = 11000101 1110 1111
;BH = 001 1 1010 before
AND BH, OFh
; BH = 0000 1010
; after the AND operation
;BX =0011110101101001
; CX = 00000000 11111111
XOR BX,CX
;BX=0011110110010110
;Please note, that the bits in
;the lower byte are inverted.
Microprocesm ,
Architecture
bsseqbly Language
RriQjogramyping
,
e
~coUnt:
--'
/., .
;if CF 0
; BX = 1000 1001
;result :CF = 1
; BX = 0001 0010
,
I
I
'
; BS = 0010 0100
;i+L=OOOl 1101 = +29
;decimal, CF = 0
,SAR 4L,01
,;AL=0000 1110=+14
;decimal, CF = 1
;OF = PF = SF = ZF = 0
,
I
numb&:
.:
.,
1 ,
:
ROR ds, eount
I s
SAR BH,Ol
; B H = 1111 1OO1=-7
;decimal, CF =1
MStrap&k.wm
Architectare'
Point out the error/ t$rors in the following 8086 assembly instruction (if any)?
a. ' PUSHF AX
'
(a) LEA and MOV instruction serve the same purpose. The only difference
between the two is the type of operands they take.
(b) NEG instructimproduces 1's complement of a number.
(e)
Suppose .ALc h a i n s 0 110 010 f and CF is set, then instructions ROL AL
'
and RCL AL will produce the same results.
Assembly Language
Programming
DESCRIPTION
RET number
27
.-
EXAMPLE
I CALL procl
CALL proc2
The new instruction
address is determined by
name declaration proc 1 is
a near procedure, thus,
only IP is involved. proc2
involves new CS: IP pair.
On call to proc 1
stack C IP
IP C address offset of
proc 1
on call to proc2
Stack [top] C CS
Stack [top] C IP
CS C code segment of
proc2
IP C address offset of
proc2
Here we assume that procl
is defined within the same
segment as the calling
procedure, while proc2 is
defined in another
segment. As far as the
calling program is
concerned, both the
procedures have been
called in the same manner.
But while declaring these
procedures, we declare
procl as NEAR procedure
and proc2 as FAR
procedure, as follows:
procl PROC NEAR
proc2 PROC FAR
LEA BX, procl
;initialize BX with the
;offset of the procedure
;procl
CALL BX
;CALL procl indirectly
;using BX register
RET 6
1 1
Conditional Jump
Microprocessor
Architecture
Unconditionally go to specified
address and get next instruction
from the label specified. The
label assigns the instruction to
which jump has to take place
within the program, or it could
be a register that has been
initialised with the offset value.
JMP can be a NEAR JMP or a
FAR jump, just like CALL.
All the conditional jumps follow 1-MOVCX. 05
some conditional statement, or
MOV BX, 04
any instruction that affects the
c ~ CX,
p BX
; this instruction will set
;various flags like the ZF,
;and the CF.
JE LABELl
;conditional jump can
;now be applied, which
; checks for the ZF, and if
; it is set implying CX =
; BX, it makes
; a jump to LABELl,
; otherwise the control
; simply falls
; through to next
;instruction
; in the above example as
; CX is not equal to BX
; the jump will not take
;place and the next
; instruction to conditional
;jump instruction will be
; executed. However, if
;JNE (Jump if not equal
; to) or JA (Jump if
above), ;or JAE (Jump
above or
; equal) jump instructions
; if applied instead of JE,
;will cause the conditional
All the conditional jump instructions which are given below
are self explanatory.
below nor equal
23
Assembly Language
prpgrarnmirg
JAEIJNB
JBIJNAE
JBEIJNA
JC
JEIJZ
JNC
JNEIJNZ
.JO
JNO
JPIJPE
JNP/JPO
JGIJNLE
JAlJ'I%
JWJNGE
JLEIJNG
,.
JS
JNS
LOOP label
'
LOOPE/ LOOPZ
label
..
decremented to zero,
wl~ichmeans all the
elements of the array are
equal to OFFh, or an
element in the array is
found which is not equal
to OFFh. In this case, the
CX register may still be
greater than zero, when the
control comes out. This
can be coded as follows:
(Please note here that you
might not understand
everything at this place,
that is because you are still
not familiar with the
various addressing modes.
Just concentrate on the
LOOPE instruction):
Mieroprocessar
Architecture
LOOPNEILOOPNZ
through a sequence of
instructions while zero flag = 0
and CX is not equal to zero. This
instruction is just the opposite of
I
Assembly Language
Programming
DESCRIPTION
This is an instruction prefix. It
causes repetition of the following
instruction till CX becomes zero.
REP. It is not an instruction, but it
is an instruction prefix that causes
the CX register to be decremented.
This prefix causes the string
instruction to be repeated, until CX
becomes equal to zero.
REPEIREPZ
REPNEIREPNZ
MOVSIMOVSBI
MOVSW
26
1
Q
EXAMPLES
REP MOVSB STRl ,STR2
The above example copies
byte by byte contents. The
CX register is initialized to
contain the length of source
string.REP repeats the
operation MOVSB that
copies the source string byte
to destination byte. This
operation is repeated until
the CX register becomes
equal to zero.
CMPSICMPSBI
, CMPSW
i
MOV CX, 10
; load leagth of string to CX
; as counter
REP MOVSB
; Decrement CX and
; MOVSB until
; CX =o
; after move SI will be one
; greater than offset of last
; byte in source string, DI
; will be one greater than
; offset of last destination
; string. CX will be equal
:to zero.
MOV c x , 1 0
MOV S1,OFFSET SRC-STR
; offset of source
; string in SI
MOV DI, OFFSET DES-STR
; offset of destination
; string in DI
REPE CMPSB
; Repeat the comparison of
; string bytes until
; end of string or until
;compared bytes are not
I ;equal.
( MOV AL, ODh
; Byte to be scanned
; for in AL
MOV D1,OFFSET DES-STR
MOV CX,lO
REPNE SCAS DES-STR
; Compare byte inDES-STR
; with byte in A .register
( ;Scanning is repeated while ; 1
the bytes are not equal and ;
it is not end of string. If a
.; carriage return ODh is
;found, ZF = DI will point ;
Microprocessor
Architecturca
Assembly Language
Programming
LODS/LODSB/
LODSW
STOSISTOSBI
STOSW
rn
How can you control processor, as this is the job of control unit?
How much control of processor is actually allowed?
Well, 8086 only allows you to control certain control flags that causes the processing
in a certain direction, processor synchronization if more than one processors are
attached through LOCK instruction for buses etc.
Note: Please note that these instructions may not be very clear to you right now. Thus,
some of these instructions have been discussed in more detail in later units. You must
MNEMONIC
STC
CLC
CMC
STD
CLD
DESCRIPTION
It sets cany flag to 1.
It clears the carry flag to 0..
It complements the state of the
canyflagfiomoto 1 or 1 t o o a s '
the case may be.
It sets the direction flag to 1. The
string instruction moves either
forward (increment SI, DI) or
backward (decrement SI, DI)
based on this flag value. STD
ins&ction does not affect any
other flag. The set direction flag
causes stings to move fiom right
to left.
This is opposite to STD, the string
EXAMPLE
CMC; Invert the carry flag
CLD
2
t
operation occurs in the reverse
direction:
Microprocessor
Architecture
There are many process control instructions other than these; you may please refer to
further reading for such instructions. These instructions include instructions for setting
and closing interrupt flag, halting the computer, LOCK (locking the bus), NOP etc.
Description
Effective address is the
displacement of memory
variable.
Effective address is the
contents of a register.
[LIST +Dl]-[DI + 21
[BX + SI]
1
29
[BX][DI]
[BP + Dl]
[BX + SI + 21
Description
In general, the register
addressing mode is the most
efficient because registers are
within the CPU and do not
require memory access.
Example
MOV AL,CH
MOV AX,CX
Mode
DIRECT
Description
Please note in the last
examples the expression (2
+ 3)/5, is evaluated at
assembly time.
Description
The direct operands are also
called as relocatable operands
as they represent the offset of
a label fiom the beginning of a
segment. On reloading a
program even in a differ&
segment will not cause change
in the offset that is why we
call them relocatable. Please
note that a variable is
considered in Data segment
(DS) and code label in code
segment (SS) by default. Thus,
in the example, COUNT, by
Example
MOV AL, 10
MOV AL,'A'
MOV AX,'ABt
MOV AX, 64000
MOV AL, (2 + 3)/5
Example
MOV COUNT, CL
;move CL to COUNT (a
;byte variable)
MOV AL,COUNT
;move COUNT to AL
JMP LABEL1
;jump to LABEL1
MOV AX,DS:5
;segment register and
; offset
MOV BX,CSEG:ZCh
;segment name and offset
MOV AX,ES:COUNT
; segment register and
;variable.
1.
2.
3.
4.
Mode
Register
indirect
Description
Indirect operands are
particularly powerful when
processing list of arrays,
because a base or an index
register may be modified at
runtime.
Architecture
Microprocessor
Example
MOV BX, OFFSET ARRAY
; point to start of array
MOV AL,[BX]
; get first element
INC BX
; point to next
MOV DL,[BX]
; get second element
The brackets around BX'signify
that we are referring to the contents
of memory location, using the
address stored in BX.
In the following example, three
bytes in an array are added together:
MOV S1,OFFSET ARRAY
; address of first byte
MOV AL,[SI] *
;move the first byte to AL
Assembly Language
Programming
and Indexed
Indirect
--
Mode
Based Indexed
Displacement
Description
In this type of ad Iressing the
operand's effective address is
formed by combining a base
register with an index register.
Example
- --. -- -MOV AL,[BP] [SI]
MOV DX,[BX SI]
ADD CX,[DII [BX]
; Two base registers or t\vo
; index registers cannot be
;combined, so the
; following would be
; incorrect:
MOV DL,[BP + BX]
;error : two base registers
MOV AX,[SI + DI]
;error : two index registers
1
1
I
I
MOV DX,ARRA?CB?(][S~]
MOV AX, [RX + SI t
ARRAY]
ADD DL,[BX + SI + 31
SUB CX, ARRAY [BP +
SII
Two base registers or two
index registers cannot be
combined, so the
following would be
incorrect:
MOV AX,[BP + BX + 21
MOV DX,ARRAY [SI +
Microprocessor
Architecture
fi.
I.
In the instruction ADD CX, [DI] [BX] the second operand is a based index
operand, whose effective address is obtained by adding the contents of Dl and BX
registers.
I 7
/
1.7
SUMMARY
In this unit, we have studied one of the most popular series of microprocessors, viz.,
Intel 8086. It serves as a base to all its successors,. 8088, 80186, 80286,80486, and
Pentium. The successors of 8086 can be directly run on any successors. Therefore,
though, 8086 has become obsolete from the market point of view, it is still needed to
understand advanced microprocessors.
To summarize the features of 8086, we can say 8086 has:
- segmented memory
- 4 general purpose registers (each of 16 bits)
- instruction pointer and a stack pointer
- set of index registers
- powerful instructien set
- powerful addressing modes
1.8 SOLUTIONSIANSWERS
Check Your Progress 1
1.
2.
Assembly Language
Programming
3.
2.
(a) False
(b) False
(c) True
(d) False
(e) False
False
True
T N ~
True
True
True
False