Micro1 PDF
Micro1 PDF
net/publication/312470984
CITATIONS READS
0 5,656
1 author:
Abdullatif Baba
Türk Hava Kurumu Üniversitesi
99 PUBLICATIONS 49 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
Genetic algorithm-based technique for predicting future generations of hazelnuts chromosomes. View project
All content following this page was uploaded by Abdullatif Baba on 17 January 2017.
20-bit
8-bit data address
20 bit address bus allow accessing
1 M memory locations control 8088 control
signals signals
To 8088 from 8088
16-bit internal data bus and 8-bit CLK
external data bus. Thus, it need
two read (or write) operations to GND
read (or write) a 16-bit datum
20 address lines => 220 = 1MB (Mega Byte) 8088 signal classification
2
The Software model of the 8088
15 8 7 0
AX AH AL Accumulator
General Purpose BX BH BL Base
registers CX CH CL Count
DX DH DL Data
Four 16-bit data registers, each one may be split up into two halves of 8 bits
15 0
SP Stack pointer
BP Base pointer
General Purpose SI Source index
registers
DI Destination index
IP Instruction pointer
7 general purpose 16-bit registers are available to be used by the programmer, they have some specific
roles :
• AX : is normally used in multiplication and division operations and also in instructions that access
I/O ports.
• CX : is normally used as a counter in loop operations providing up to 65,536 counts
• DX : is may be used in multiplication and division operations and also a pointer when accessing
I/O ports 4
• SI and DI : are used as pointers in string operations.
The Software model of the 8088
15 0
CS Code segment
DS Data segment
SS Stack segment
ES Extra segment
Segment registers, are used by the processor to control all access to memory and I/O and
must be maintained by the programmer
• CS: used during instruction fetch
• DS: used by default when reading or writing data
• SS : used during stack operations such as subroutine calls and returns
• ES : used fore anything the programmer wish
15 0
Flags
To indicate the result of arithmetic and logical instructions. (Zero, parity, sign, carry…..)
8088 is composed of two internally divided functional units
• Bus interface unit (BIU)
• Execution unit (EU)
Bus
control
ALU Instruction Queue External bus
EU
control
Flag register
BIU is composed of :
• Address adder
• Segment registers
• Bus control unit
• The instructions queue.
7
Organization of 8088
• When the EU is ready for the next byte, it will be pulled from the queue.
• BIU pre-fetch the next byte from the memory and so on …..
• The instructions pre-fetched by the BIU are incorrect and are discarded
• The next (appropriate) instruction is fetched from the new address and the queue is
reloaded
8
8088 is composed of two internally divided functional units
• Bus interface unit (BIU)
• Execution unit (EU)
Bus
control
ALU Instruction Queue External bus
EU
control
Flag register
EU is composed of :
• ALU (Handling Arithmetic and logic operations)
• All general purpose registers
• Pointer registers
• The execution control unit.
10
Generating Memory Addresses
How can a 16-bit microprocessor generate 20-bit memory addresses?
DS Data Segment
Segment = a 64kbyte memory
SS Stack Segment block beginning at a multiple
ES Extra Segment by 10H address.
Generating Memory Addresses
An physical address is generated as combination between a segment register and
another register as in the following example.
Example :
CS Code Segment
Shift DS Data Segment
to left 16 bit
4 bits SS Stack Segment
ES Extra Segment
A000 + Add
5F00 16 bit
A5F00
IP Instruction Pointer
SP Stack Pointer
Physical FLAGS Flags
Address 16 bit registers
(20bits) 12
Memory Address Calculation
Examples
CS 3 4 8 A 0 SS 5 0 0 0 0
IP + 4 2 1 4 SP + F F E 0
Instruction address 3 8 A B 4 Stack address 5 F F E 0
DS 1 2 3 4 0
DI + 0 0 2 2
Data address 1 2 3 6 2
13
Fetching Instructions
Where to fetch the next instruction?
8086 Memory
CS 1234
IP 0012 12352 MOV AL, 0
12352
Update IP
— After an instruction is fetched, Register IP is updated as follows:
— For Example: the length of MOV AL, 0 is 2 bytes. After fetching this instruction,
the IP is updated to 0014
14
Reserved Memory Locations
Some memory locations are reserved for special purposes.
Programs should not be loaded in these areas
FFFFF
Locations from FFFF0H to FFFFFH Reset FFFF0
are used for system reset code instruction
area
15
Flag register
Flag register contains information reflecting the current status of a microprocessor.
It also contains information which controls the operation of the microprocessor.
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
CF Carry Flag Contains Carry out of MSB of result
PF Parity Flag Indicates if result has even parity
AF Auxiliary carry Flag Contains Carry out of bit 3 in AL
ZF Zero Flag Indicates if result equals zero
SF Sign Flag Indicates if result is negative
TF Trace Flag Provides a single step capability for debugging
IF Interrupt enable Flag Enables/disables interrupts
DF Direction Flag Controls pointer updating during string operations
OF Overflow Flag Indicates that an overflow occurred in result
DF, IF and TF are Control Flags, the others are called Status Flags
16
Carry Flag (CF): Bit 0
- The carry out or borrow out from MSB in the last arithmetical operation.
- CMP (Compare) instruction is a subtraction without a saved result. Carry bit is affected.
- CF is not affected by other types of instructions (i.e. MOV, JMP, etc)
AL C
MOV AL, AAH 1010 1010 X
RCL AL 0101 010X 1
Examples :
- +
CF = 1; if there is a carry out or borrow out from MSB in the last arithmetical operation.
Otherwise CF = 0;
18
Parity Flag (PF): Bit 2
Set (1) if an even number of bits in the lower byte of the result are “1”.
Examples: AL P
MOV AL,0FFH 1111 1111 1
AL P
MOV AL,07H 0000 0111 0
19
Auxiliary Carry Flag (AF): Bit 4
The carry out from bit 3 to bit 4 in the last arithmetical operation.
AF = 0
20
Zero Flag (ZF): Bit 6
Set (1) if the result of the last arithmetical or logical operation was 0.
CMP (Compare) instruction is a subtraction without a saved result. Zero bit is affected.
Not affected by other types of instructions (i.e. MOV, JMP, etc)
The MSB (Most Significant Bit) of the last arithmetical or logical operation result.
The processor doesn’t knows if the result is to
Bit 7 for byte operation
be interpreted as “signed” or “unsigned”. S flag
Bit 15 for word operation
is always generated. It is the programmer
Bit 31 for double-word operation
responsibility to test or not the S flag.
CMP (Compare) instruction is a subtraction without a saved result. Sign bit is affected.
Not affected by other types of instructions (i.e. MOV, JMP, etc)
AX S
MOV AX,7FFFH 0111 1111 1111 1111 X
INC AX 1000 0000 0000 0000 1 22
Overflow Flag (OF): Bit 11
It becomes 1 if the last calculated result would not fit in the number of
bits used for the operation, this may happen in the following cases :
Example :
The overflow flag is set when the most significant bit (the sign bit) is
changed by adding two numbers with the same sign (or subtracting two
numbers with opposite signs).
Overflow never occurs when the sign of two addition operands are
different (or the sign of two subtraction operands are the same).
23
Flag register
Interrupt enable Flag (IF): Bit 9
It is manipulated by the programmer. If the flag is set to 1, hardware
interrupts will be authorised. If it is set to 0, interrupts will be ignored.
28
Instruction types
String instructions
8088 instruction set
CMPS Compare byte or word string
LODS Load byte or word string
MOVS Move byte or word string
MOVSB(MOVSW) Move byte string (word string)
REP Repeat
REPE (REPZ) Repeat while equal (zero)
REPNE (REPNZ) Repeat while not equal (not zero)
SCAS Scan byte or word string
STOS Store byte or word string
29
View publication stats