



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The course is to provide both theoretical background and practical skills in microcomputer (x86) system design. Both hardware and software development (assembly language) and debugging tools are included in the laboratory experiments. Key points in this lecture are: Programming Model, Internal Registers, Microprocessor Programming Model, Programming Model for Intel 80386, Program Visible and Invisible Register, Intel 80X86 Registers, Software Model of the 8088 Microprocessor, General Data Regist
Typology: Slides
1 / 27
This page cannot be seen from the preview
Don't miss anything!




















The programming model (software) summarizes all the informationneeded for programming the microprocessor.
a
Example: 8088 Programming Model 4
SegmentRegisters
4 Data Registers
2 PointerRegisters2 IndexRegisters
1 FlagRegister
bit 15
8
7
0
15
0
AX
AH
AL
Accumulator
SP Stack pointer
BX
BH
BL
Base
BP Base pointer
CX
CH
CL
Count
SI
Source index
DX
DH
DL
Data
DI Destination indexIP
Instruction pointer
15
0
CS
Code segment
15
0
DS
Data segment
Flags
SS
Stack segment
ES
Extra segment
: Only available in80386 or higher
8-bit
Names
32-bitNames
16-bitNames
EAX
AH
AX
AL
Accumulator
EBX
BH
BX
BL
Base index
ECX
CH
CX
CL
Count
EDX
DH
DX
DL
Data
ESP
SP
Stack pointer
EBP
BP
Base pointer
EDI
DI
Destination index
ESI
SI
Source index
32-bits
16-bits
EIP
IP
Instruction pointer
EFLAGS
FLAGS
Flags
CS
Code
DS
Data
ES
Extra
SS
Stack
FSGS
00000
16
FFFFF
16
8088 CPU
IP CSDSSSES
AH
AL
AX
BH
BL
BX
CH
CL
CX
DH
DL
DX SPBPSI DI
SR
The segment registersin CPU store the initialaddress information ofthe corresponding memory segments
SR: status (flag) register
Code segment(64 K bytes)Data segment(64 K bytes)Stack segment(64 K bytes) Extra segment(64 K bytes)
memory
Q: 16-bit
→
20-bit?
The segment register is16-bit, but the physicaladdress is 20-bit
20-bit
a
This set of registers usually stores offset addresses of memory. IP usuallystores the offset address of the next instruction in memory. SP, BP, DIand SI usually store the offset address of data in memory.
a
SP, BP, DI and SI may also be used for general purposes.
a
SP (Stack Pointer) is used in the PUSH and POP instructions foroperations on a LIFO (Last-In, First-Out) stack.
a
BP(Base Pointer) is often used in addressing an array of data in the stackmemory.
a
DI (Destination Index) usually stores the indirect destination address ofdata from an instruction.
a
SI (Source Index) is used when indirectly addressing source data incertain string instructions.
Destination IndexInstruction Pointer
15
0
SP
Stack pointer
BP
Base pointer
DISI
Source Index
IP
BIT
8085 COMPATIBLE FLAGS
15141312 11
10
9
8
7
6
5 4
3 2
1
0
U=
CARRY FLAG - SET UP CARRY OUT OF MSB
UNDEFINED
PARITY FLAG – SET IF RESULT HAS EVEN PARITYAUXILIARY CARRY FLAG FOR BCDZERO FLAG – SET IF RESULT = 0SIGN FLAG = MSB OF RESULTSINGLE STEP TRAP FLAGINTERRUPT ENABL
E FLAG
STRING DIRECTION FLAGOVERFLOW FLAG
a
Flags in the FLAGS register are either condition or control flags.
a
Condition flag consist of :
`
C (carry flag) - set to 1 when the result of an addition has a carry out of themost significant byte. Other instructions can also affect C (e.g. subtraction) `
P (parity flag) - set to 1 if the low-order byte of the result contains an evennumber of ones; otherwise it is set to zero. `
A (auxiliary carry flag) - set to one if there is a carry-out of the bit-3 during anaddition or a borrow by bit-3 during subtraction. `
Z (zero flag) - set to 1 if the result is zero; Z is otherwise zero. `
S (sign flag) - equal to the most significant bit of the result (i.e. set to 1 if theresult is negative) `
O (overflow flag) - set if a result is out of range (e.g. when adding two positivenumbers and the result appears negative)
a
Three bits (D, I, T) in the flags register control the operation of themicroprocessor under the following circumstances:
D (direction flag) - in certain string manipulation instructions, Ddetermines whether the string is processed from the lowest address(D=0) or the highest address (D=1). `
I (interrupt flag) - determines whether a maskable interrupt isrecognized by the microprocessor. If I=1, a maskable interrupt ispossible, otherwise the interrupt is ignored. `
T (trap flag) - if T=1, a trap (e.g. for single stepping through a program)is executed after every instruction.
D=0: auto-incrementD=1: auto-decrement
Segment Registers are 16-bit registers (in CPU) used in conjunction withthe index and pointer registers to generate the physical 20-bit address.
Memory segments (in Memory): a
Code Segment is the section of memory used to store the programinstructions and procedures. CS register stores the starting address of theprogram code. In the 8086 (and 80286) the code segment is limited to64K bytes in length (in 80386 the maximum length is 4G bytes).
a
Data Segment contains data used by the program. DS register stores thestarting address of the data segment.
Bit-
bit-
CS
CODE SEGMENT Register
DS
DATA SEGMENT Register
ES
EXTRA SEGMENT Register
SS
STACK SEGMENT Register
Extra Segment is another data segment which is used by some stringinstructions.
a
Stack Segment is the section in memory called stack which is used forstorage of register contents and data.
a
A segment in the 8088 system is a continuous section of memory of up to64K bytes (64K of 1-byte information; or 64 KB) in length.
a
The 64-Kbyte block defined by the start address of a segment mayoverlap with other segments or be completely in its own separate area ofmemory.
-- Don’t try it unless you really know what you are doing.
a
Segments
allow
packages
of
information
(e.g.
a
data
table,
or
a
subroutine) to be kept separately - it is not necessary to fill all 64K of thesegment and the programmer can make the segment of arbitrary size (upto 64K bytes, in 16 bytes increments).
a
Since the segment address is derived by shifting 4 bits to form the 20-bitaddress, the start address of a segment can only occur at 16 data bytesintervals. Valid start address 00000h, 00010h, 00020h, …
a
Increasing the value of segment register by 1 will increase the physicalstarting address by 16.
a
Advantages of the segment + offset method include
Program code can easily be reallocated in memory (useful for multi-tasking) `
Most operations can be performed by changing only the 16-bitoffset. The offset can be stored in 16-bit registers (No need for 20-bit registers to store the address), allowing for easier interface to 8-and 16-bit wide memory.
Q: How do we know which Segment Address shall be used for a given offsetaddress?
a
The microprocessor has a set of rules that define the segment registerand offset register combination used by certain addressing modes.(Implication: you may not need to to specify the segment register used)
a
However, the default can be overridden by using the segment overrideprefix:
(move a byte from location SS:[BP] to CL)
or
Offset register
DefaultSegment register
Override Prefix
IP
CS
Never
SP
SS
Never
BP
SS
DS, ES or CS
SI, DI (not include strings)
DS
ES, SS or CS
DI for string instructions
ES
Never