You are on page 1of 89

| |

 
| |
   
| |

‡ 16-bit Arithmetic Logic Unit


‡ 16-bit data bus (8088 has 8-bit data bus)

‡ 20-bit address bus - 220 = 1,048,576 = 1 meg

The address refers to a byte in memory. In the 8088, these bytes come in on
the 8-bit data bus. In the 8086, bytes at even addresses come in on the low
half of the data bus (bits 0-7) and bytes at odd addresses come in on the upper
half of the data bus (bits 8-15).

The 8086 can read a 16-bit word at an even address in one operation and at an
odd address in two operations. The 8088 needs two operations in either case.

The least significant byte of a word on an 8086 family microprocessor is at the


lower address.
a   
  

4  

4  
 
        
     
 
 

 
V  
 
   
 



 



 
4


4 4
4 a  



a

   

 4

 
| |  

‡ The 8086 has two parts, the Bus Interface Unit (BIU) and the
Execution Unit (EU).

‡ The BIU fetches instructions, reads and writes data, and computes the
20-bit address.

‡ The EU decodes and executes the instructions using the 16-bit ALU.

‡ The BIU contains the following registers:

IP - the Instruction Pointer


CS - the Code Segment Register
DS - the Data Segment Register
SS - the Stack Segment Register
ES - the Extra Segment Register

The BIU fetches instructions using the CS and IP, written CS:IP, to contract
the 20-bit address. Data is fetched using a segment register (usually the DS)
and an effective address (EA) computed by the EU depending on the
addressing mode.
The EU contains the following 16-bit registers:

AX - the Accumulator
BX - the Base Register
CX - the Count Register
DX - the Data Register
SP - the Stack Pointer \ defaults to stack segment
BP - the Base Pointer /
SI - the Source Index Register
DI - the Destination Register

These are referred to as general-purpose registers, although, as seen by


their names, they often have a special-purpose use for some instructions.

The AX, BX, CX, and DX registers can be considers as two 8-bit registers, a
High byte and a Low byte. This allows byte operations and compatibility with
the previous generation of 8-bit processors, the 8080 and 8085. 8085 source
code could be translated in 8086 code and assembled. The 8-bit registers are:

AX --> AH,AL
BX --> BH,BL
CX --> CH,CL
DX --> DH,DL
„ 
| |   !  

ES Extra Segment
BIU registers
(20 bit adder) CS Code Segment
SS Stack Segment
DS Data Segment
IP Instruction Pointer

EU registers AX AH AL Accumulator
BX BH BL Base Register
CX CH CL Count Register
DX DH DL Data Register
SP Stack Pointer
BP Base Pointer
SI Source Index Register
DI Destination Index Register
FLAGS
| |||
       

  


    
     


       


!!2 "

#


  


$ !     


   %   !
 &%!!
| || ||&  '(  

) (  
* (    +,  % % !
*     
) -
  %  %!
)  .     
*    
) -
  %     
!
) $ !   $$/$$$
) +   $++0+
) 01   $00
* $    
) 2     % 
) 3 0&+      

#45$  
* 0
 %  6    | || ||
  (   '

) 0   1 % %      


)      
) 4 -  %        
  

* ----  
* 444 4 

)   (     
      

%! 
% 
) 
*  !
(  
* +%    !
      %   
      & 4  
* &  !

  7  
* & 
 03 
) 
*  (  
* 
 7       

) 
*    
* ,   
 
* ,  %   
) 
*     
* , !

  7 
* 
 03 
+ 01(  

)  %%    %!!


 
)  
  !  
) $+'$ 8
* , $$    8  !
) +' +
* +! 
       8
*         !
) $0'$ 01  
*  9 % !   
* :     %!$0   
!!
      !   
$  " $0   $  
  "
) 0'  01  
*  
9 % !    "
* :     %!0   
!!
      !   
/$  " 0   /$  
  "
) $0 0   ! 
     
  
$ !(   6 $$$$ /$

)    


) $!!   %     
) &!3 ; 
* / !!          6  
! %  
!!
*    1  <1  %! 6 #####
* +
!'      3305 %    =
* $
'&!$ !
) 
8%.2<<>  7!!
)   ! !    !
) $ ! !   %! ####
) :   !  
!!
   % %% 
) %% 
   %! ####
a     
a        "# $ %   
 #   &'(#    )   '(#  && 


| "
0

   
/
|
.

| " *-
-
*-
,
+ | "
*
'
 &
V

&! 5 


) 0,    %
!  
!!  
Offset Value (16 bits)

Segment Register (16 bits) 0000

§ 

Physical Address (20 Bits)


V

/1 !
 


) 0%    !    
  
   %    
?  
  @
 ?

3%% ' 0000000000101001

$ !' 0001000000000000 0000

 ' 0001000000000010 1001


$ !'3%% 

) 4 
   %   !'%% 
) + 
     %   !  .
 
%   %%  
)   
  %
 
  .#'.|A
.#
B .|A
?|
*  111
2      3      4 && 
   *|" + 5

*| 6 + 7 */*

§8   9    &    1


* 111
2        3       
*|+ 5

 &&  ( &&    3  


   *|+ 1 9 3"
*| " + :*|+" :*| " ,+ :111
$ !
0H

4000H
CS: 0400H

IP 0056H 4056H
CS:IP = 400:56
Logical Address

?emory
0400 0
Segment Register

Offset + 0056
Physical or 04056H
0FFFFFH

Absolute Address

The offset is the distance in bytes from the start of the segment.
The offset is given by the IP for the Code Segment.
Instructions are always fetched with using the CS register.

The physical address is also called the absolute address.


  $ !
0H

05C00H
DS: 05C0
05C50H
SI 0050 DS:EA

?emory
05C0 0
Segment Register

Offset + 0050

Physical Address 0FFFFFH


05C50H

Data is usually fetched with respect to the DS register.


The effective address (EA) is the offset.
The EA depends on the addressing mode.
$ 8$ !
0H

0A00 0A000H
SS:
0A100H
SP 0100 SS:SP

?emory
0A00 0
Segment Register

Offset + 0100
0FFFFFH
Physical Address 0A100H

The offset is given by the SP register.


The stack is always referenced with respect to the stack segment register.
The stack grows toward decreasing memory locations.
The SP points to the last or top item on the stack.

PUSH - pre-decrement the SP


POP - post-increment the SP
#

 %

37%

 + %

0  
  1
 %

  C

    %
$ 
> 
%

 „ 
) 
%
'
*      !
 % ! "D 

7
  
%"
) 
%
'
* , 
 !  %&+," %
  
  7 ! %   "
 ; 0 < a  §  

'
  1 '- ', '+ '* '' / | .  - , + * '

) #    %!


%! %

 
!
  
%!  % 
 "
 „ 

) 3#7%
0  7%
%

%!    !"
) #0  
% %
!7 !      "
) 0# 0  1

      "
) # +!  % 
 
 !"
) $#    
   % 
!  E 7
) C#;0  
%
! !   ;" E 
) # 1
      %
>.% 
; !"
) +# 0   !%  
 
%!  "
§  
 

- Register  immediate  8 ) 




;= §:'
;= :§

   
+ +( | 9|  #
> <3    
- §#    

;= §:? * @

)        0a" *


+ +( | 9|  #
> <3    
- „   

;= §:?@

)         0a"


+ +( | 9|  #
> <3    
- 0 3 

;= 0 :,
;= §:? * 60 @

)   0a" * ,
+ +( | 9|  #
> <3    
-  9

;= : *
;= 0 :,
;= §:?60 @

)   0a" * ,
+ +( | 9|  #
> <3    
-    
;= 0 : * ,
;= :?0 @
;= §:?@

&0a" * ,    *-:


 §8   
8 )    
0a" *-
+ +( | 9|  #
> <3    
-     K  

 
;= 0 : * , 

;= :?0 @ 

;= §:?@
K
 

&0a" * ,    *-:  

 §8   


8 )    
0a" *-  
| | 9   
The IB? PC is a maximum mode 8088 system. When an 8086/8088 is used
in the maximum mode (?/?X pin grounded) it requires the use of an 8288
Bus Controller. The system can support multiple processors on the system
bus by the use of an 8289 Bus Arbiter.

The following signals now come from the 8288: ALE, DT/R¶, DE, and ITA¶.

The ?/IO¶, RD¶, and WR¶ signals are replaced by:

?RDC¶ - memory read command


?WTC¶ - memory write command
IORC¶ - I/O read command
IOWC¶ - I/O write command
A?WC¶ - Advanced memory write command
AIOWC¶ - Advanced I/O write command

The advanced commands become active earlier in the cycle to give devices
an earlier indication of a write operation.

IV-1
| |9   
When in the maximum mode, the 8086/8088 has 3 status lines that are
connected to the 8288 and provide it with the information it needs to
generate the system bus signals. The information provided by the status
bits is as follows.

S2¶ S1¶ S0¶ operation signal


0 0 0 Interrupt Acknowledge ITA¶
0 0 1 Read I/O port IORC¶
0 1 0 Write I/O port IOWC¶, AIOWC¶
0 1 1 Halt none
1 0 0 Instruction Fetch ?RDC¶
1 0 1 Read ?emory ?RDC¶
1 1 0 Write ?emory ?WTC¶, A?WC¶
1 1 1 Passive none

IV-2
0  § ( 0§
D?A allows data to go between memory and a peripheral, such as a disk
drive, without going through the cpu.

The D?A controller takes over the address bus, data bus, and control bus.
The 8237A D?A Controller is a commonly used device and is in the IB? PC.

Figure 11-4 is a simplified block diagram showing the use of a D?A controller.
For example, to read a disk file the following operations occur.

1. Send a series of commands to the disk controller to find and read a


block of data.
2. When the controller has the first byte of the block, it sends a D?A
request DREQ to the D?A controller.
3. If that input of the D?A controller is unmasked, the D?A controller
sends a hold-request HQR to the cpu.
4. The cpu responds with a hold-acknowledge HLDA and floats its buses.
5. The D?A controller then takes control of the buses.
6. The D?A controller sends out the memory address and D?A
acknowledge DACK0 to the disk controller.
7. The D?A controller asserts the ?E?W¶ and IOR¶ lines.

IV-4
 
Terminology
Volatile - data is lost when power is turned off.
onvolatile - retains data when powered off.

Random Access - all data locations accessed in the same amount of time.
Sequential Access - data accessed in varying amounts of time, e.g., tape.

RO? - Read Only ?emory.


RA? - Random Access ?emory

By convention, RA? in a PC is really Read/Write ?emory and RO?


(EPRO?) in a PC, although random access memory, is not referred to
as RA?.

Examples
VOLATILE OVOLATILE
Static RA? RO?, PRO?, EPRO?, EEPRO?, FLASH
Dynamic RA? Disk, tape
?agnetic core, magnetic bubble

IV-6
&| | ''  „§
| |  -/G
 21|
  6 
  6 

FFFF 4  A6 
A6  FF

-/
 ?6  (:
4/
3/G
7
 
$G

 (&$G

FF   6   6 
&/&G A6 
&03
FFF  <6| FF 
:( (:
FFF 
3/G
( $G
-/G

(/D : 
$ 
„( '//. 5 ,.
V 


   
  
2  §  #
>  (a3 &   
- (   3  #8   
  )  
-         
 
> (§ #
- &  | |:| ||:| '|:| *|:| +|:
| ,|:    
2  §§ #5
> a  ) 
-    #   
 
> #A& (         :   
:  &    8    
3 
>   & (       &   
3  : # :   :  
  :  # #
2 § #
5
>  8 > § 8   &
3  8 B  &&  
>    #  3 
 3  > § 8 3  
> 93     #3  ()
3   &     
     >  #  
> C       3  
 8 3 3 
0„3  
>   (' > 2  ( ' 
- 3    & -  
   3   &    8
    3 D8  EF
  > 0 #8  ( +* 
>  (     > G 8  ( , 
> ( |  > H##( , 
-    #
   $ 
 (%
H# a 
>  (  * > „8 & 
- :' - § &   
> ;(  |   &  
 
- :':*:I.
- 9:8
> 0 (  '   93 
- :':*:I:/ &   
> 9  $9%    : 
   & 
- :':I:/:§::I:    # 
0 
> „8 >     
- ' ' # -  §
> 9 > §a  
--  - !
> ; > 
- '* | - | $ %
> 0  > 0
-| - - $& &%
>    555
 
> § &# : 
  !    a
- <  &#  3  3  
3& 
>        #
>    #   #
> )#  3   
  
§ #)  
  

>    


- 2    &# 3  
#  &      #9 
      #  #3 
> § #  
-   #       3 
8 8 &  
3        
§ #
  
>    3  
  
-     3   
    
- < #3&    
> a    J  3
- ;3 3 )    &  
>  :  :  : ) #
> § #0  )
8086 Instruction - Basic Structure
Label Operator Operand[s] ;Comment

Label ( 3 3   
'  #i : ::::
  #
Operator (  #   
mnemonic"   & & 
§ #      9  opcode
93"Ú  &|
Operand[s] (  +3   & J  #   
# ) &&& 
0  # 
 : :  :  
Comment ( 9 &  #

These fields are separated by White Space (tab, blank, \n, etc.)
8086 Instruction - Example
Label Operator Operand[s] ;Comment

V V
i  


 
i

# ( V V
;3  (

;3  ( i  
  ( 3   #8  

> H     )
>  B  # :     3  &  
>
mnemonic  #    
opcode
Assembler Language Segment Types
> aB
-       
- a &  &   E
-  )9'
> 0
-     a 
- a &  &   E
- a &  &   $ 3 %
- )   
>  
-      
-  )'  
Using ?AS? Assembler
>  3"
 i 
> A  ) B§a8   "
 i
a  
Ú a Õ 
 
Ú  
a 
  a
 
  

 a ( § # & 33 #3 


  ( <   & # #
 a (   & :  D<  F3 
K   :§   :a#  :
  -  && 
x86 Instruction Set Summary
(Data Transfer)
  
 !

!"#€ $
 % 
 !
!"
%
&'$€%$ $
V  V&
#() #
i"(!
)'i*
#%+ #
i"
!
%+
#, #
i",
!*!
#,+ #
i"
!
,+
#-%+ #
i" 
!i+V
$
.-/ .

.-/+ .
 
!i+V
%V
-0 -&&
1-1 1

1-1) 1
)'i*
10+( 1&
10+() 1&)'i*
+() +
!(
)'i*
+-+ +
!$
 
!i%V
$(2 , i*
$# !i'i
#
x86 Instruction Set Summary
(Arithmetic/Logical)
 +VV"3&
!""$
% +VV"3&
!% "$
. +VV"3&
!.&''$
+ +VV"3&
!+&!i$
% ""4i!!
%% ""
 % #
*i' %
. 
' i!!
.1 
i!
.1+ 
i! 
!i+Vi"%V
% % i'"3&
!""$
%+ % i'"3&
!+&!i$
%, %! 
%V/ % "5&*"6$5 %$6
V%V/ % "5*"6$5 %$6
.0# .&''5&*"6$5 %$6
V.0# .&''5*"6$5 %$6
V  V! 
x86 Instruction Set Summary
(Arithmetic/Logical Cont.)

,2  *i
- #
*i' -
-7 #
*i''& -7
7# 7
i!
&*i!!#
77 7
i!
&*i!!7*
7-# 7
i#
7-7 7
i7*
+7 +! 7*
+ +&!i4
!!
4
++ +i 
!i%V
i!"
$
+(#+# +'
*i'! #
+(7 +'
*i'7*
+0 +&!i
,+  %&

'i*
$# !i'i
#
$-7 #
*i', '& -7
x86 Instruction Set Summary
(Control/Branch Cont.)
## i''
# 'i!i!!
#% 'i!%!

#V 'i!V!!&
,+ ,i5
 !i'" 6
(# (i'
V  V!!&
V - V!!&
- !'
4
V7, V!!&7&!
88 , 8& 
'
4


!,9&i'
8,8  8& 
'
4
!,9&i'


8$ 8& 
$!

8,8 8& 
,9&i'!

8#8 2, 8& 


#
2!i!
!,9&i'
8#,8 2 8& 
#
!,9&i'
2!i!
8.1 0
"
i'8& 
8 8, 8& 

'
4

!,9&i'
8 ,8 8& 

'
4
!,9&i'

8 ,8  8& 

,9&i'
!

8 #82, 8& 

#2!i!
!,9&i'
x86 Instruction Set Summary
(Control/Branch)
8 #,82 8& 

#
!,9&i'2!i!
8 - 8& 

- !'
4
8 181- 8& 

1i!1i!-""
8 + 8& 

+*
8- 8& 
- !'
4
8181, 8& 
1i!1i!, 
8+ 8& 
+*
#-: &#
;! 
#--1 #

$ 
#--1 #--1 , #

4'
!

,9&i'
#--1#--1, #

4'!
,9&i'
-1 
-!i
5<$(2$ $6
7,17,1 ,7,1  7i7i
,9&i'
!

7,1,7,1 7i,9&i'!

7, 7&!!
i''
+,2 +* !*!
+ +i!!
+% +%!

+V +V!!&
,+  %&

'i*
V  i
Assembler Directives

ð ð %  !



 
% H     I%  8 
%% %%
 !%  !  ! 
 % 
    %! %
  %


 
%
  %

" ! 8  %  !
"  ! 8  %    !
"  8  ;%  8  !
Assembler Directives
 %
 % 
 % 
. 
9 %9 | 
 % 
9 9    !1   !
÷ 2ð
  @%  
7
 %
J-

K %< $009 7
%J-

K"
! 1 9 >AA
  9 G I

 7
 
Program Example


i i '!
*!i =V! 
i!i!!*>(''

!'">
%-+i"i!"
&&
&*%-+! !!& &
?=


''
;+,2., @,+:A+:A%i;* 
%BCC%0156+ i  & i;
DEF5BCC6
''
;, %+

''
"i+,2., @,A%A%"ii* 
"
!,G0?"i
i i,G0
!*%A(''

!'"A BH BC AA%i!i!!*
''
"i, %+

''

"+,2., @,A-%,A%
"* 
+7
i +,2''
"ii I "ii* i!i""!

" i "I i'"ii* !*!

i "
!iI ?%-+DB!*&


" -))+,!*" I **
!*
DB%-+! !!&

i JCCi I J%-+DB!
*!i i'&

DB%-+! !!&
''

", %+
, %+7K, %'i'L"!
*!i !
Another Way to define Segments

0Ai& A"! 
"* 


''
;+,2., %i* 
%BCC%0156
''
;, %+

''
"i+,2., "i* 
"
!,G0?"i
i
!*%A(''

!'"A BH BC AA%i!i!!*
''
"i, %+

''

"+,2., "i* 
i& ''

" "''
"i ''
;
+7
i ''
"ii I "ii* i!i""!

" i "I i'"ii* !*!

i "
!iI ?%-+DB!*&


" -))+,!*" I **
!*
DB%-+! !!&

i JCCi I J%-+DB!
*!i i'&

DB%-+! !!&
''

", %+
, %+7
*et another way to define Segs

0=i; ="ii =
""! 
"* 
 

=i;BCC!! DEF
i;i

="ii
"
!,G0?"i
i
!*%A(''

!'"A BH BC AA%i!i!!*

=
"

+7
i +,2!*i I "ii* i!i""!

" i "I i'"ii* !*!

i "
!iI ?%-+DB!*&


" -))+,!*" I **
!*
DB%-+! !!&

i JCCi I J%-+DB!
*!i i'&

DB%-+! !!&

, %+7
 a
i 
!i

!i"56

> ;3  3 &    ) 
8 
-   ( #   3  
-  )( 3  ( 3  
> a3 # 3    & 
>   # 8     
>   #      )
 0 a 
>   ( 3   &  > <   ) 
  ) J    
  3
- 0( #$ % - &  
- 02( 8  $ %  
- 00( #8  $ % - 3 &  &
- 0G( J 8  $ %    )& 
(  
- 0<( #$ %
0&  0
> H  ) > §  &) 
- ' (   #  ( 
- ' ( #  &  8  ,
- ' ( 9      )8 
- ' ( §a % JC( BC BH C
- ' ( §a > §53  
>  33 3      E   
0 H  )   
$#:8  :1% %DEE  BDM A$A
H a   
> H # > §H&  #
   8     :
       E  
 & % J > <98    
% BN    
- ,
0 -% B > ;H H;&
$%%   8 
> <    >     E 
) # #8 
§
> §   )      &
 E# 
$% JC( BC BH C
@%Aii!!iA
%% BC?DHF ))))))))(  B BCC
>  3   &:6*:6,:6|
>  3   &**:*6':I:*6'-
>  3   &:6,:6|:6'*
0
> § 8  J &      
# &    )
> ;    3  & & 
 )
%JC%0156
% BC%015C6
%H"&5>>6
2  a 

> 2  : #8  : J 8   


    ) #   $ 
 %
%! +
!i*
% DEFCCCB
%%BDHJEFN(FNJEDHCB
%GBCCCCCCCCCCCCCCCC
$% HE%%HE
 8# & : # & 6'
H   
> a#      8   
   3   
> H     #    
3  3 & )    #
93 
> H    #    
> a     # & 
> H      &  )
Ja 0  )
> 793 
- 93  # 
-   #  # &   
i <N)))

&<B
% 
&

&<
&OD
% 
&
G0  )
> G93 
- 93 #    
-  L M  3 &  G
-   #    # &   
3 
i ',G0N)
i+!*,G0IB=DHJ
i*,G0Ii i*
0< &   
> ;=target, source > # (
- :  
- : 93  #
- :  
- :  > ;= #8
- :    
> a E  &#    '(# 
3  #  3 #

a3;=   
"J) > 2) #  8 
4"4DCJM &   ):    
& E #$#:8  :

' " %

i 4 > *   E #

   §

i' DEE #
#,#@,

4 BCC i
!"% ?N)D

 C
§   8 0 3
"J) DC H > < #
4"4DCJM  BCC C  3   
#   

 4PD 93 

PB i > ´OTE: These are

i PE address computations

" 4 H done at assembly time
? 
> <3B     
will not subtract 1 from
&&
the value stored at b
C
> Ctarget, source > < 3 )  
- : &&    
- : 83 3
- : - H 3   
 
> ;= C
 3&  - a   &J  
 3 & 3 
   
- < 8 B  8 
 )  
§     
§00dest, source > source #
adest, source  :
Hdest    : 
  
0dest
> dest # 
HCdest    
> Operands must be of - 93 3 
the same size  # #
 
 aa
> 0a > aBa
- a & ) # -      
- = #     &  B
 3   - aB   
&&  &   &  3   &&  
      
>  a > a  )
-    9# ="ii
    =
"
=i;@ 
  
> 1 memory_model
-  " 6 L7,N$1 3 %
- " L7,N: L7,N:  &
-  " L7,N:   
-  3" L7,N:   
- " 3    
- " 8   )   9 ,N
- &"   :+*(#    :3  
  $| +|  %
 aB 
=
"' i'' > a  
=i;BCC( > 0&  B E
="ii > 0) #
"'i!i
 > 2  
=
" -  E  3  
i!
 > B  & 

" & 
i" - 3 : & 
3 

!!

" i

You might also like