Introduction to Microprocessors
Chapter 3
Programming Model (8086)Shows the various internal registers that are
accessible to the programmer
General Purpose Registers
Data Registers
Pointer and Index Registers
Example
MOV AH,[SI]Assume SI=1000After executing programAH = 26H
Status and Control Flags
Flags Carry Flag (CF) - this flag is set to 1 when there is an unsigned overflow. For example when you add
bytes 255 + 1 (result is not in range 0...255). When there is no overflow this flag is set to 0.
Parity Flag (PF) - this flag is set to 1 when there is even number of one bits in result, and to 0 when there is odd number of one bits.
Auxiliary Flag (AF) - set to 1 when there is an unsigned overflow for low nibble (4 bits).
Zero Flag (ZF) - set to 1 when result is zero. For non-zero result this flag is set to 0.
Sign Flag (SF) - set to 1 when result is negative. When result is positive it is set to 0. (This flag takes the value of the most significant bit.)
Trap Flag (TF) - Used for on-chip debugging. Processor operate in a single stepping mode.
Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to interrupts from external devices.
Direction Flag (DF) - this flag is used by some instructions to process data chains, when this flag is set to 0 - the processing is done forward, when this flag is set to 1 the processing is done backward.
Overflow Flag (OF) - set to 1 when there is a signed overflow. For example, when you add bytes 100 + 50 (result is not in range -128...127).
ExampleIf AL=7F and instruction ADD AL,1 is given,
the flags are (7F+1=80H)CF=0PF=0AF=1ZF=0SF=1OF=1
Memory Address Space and Organization
Memory space of 8086 consists of 1,048,576 bytes or 524,288 16-bits words
Even addressed and odd-addressed banks
IF 16-bit word begins at an odd address, 8086 will require two memory read or write cycles
Origin and Definition of a Segment
A segment is an area of memory that includes up to 64Kbytes and begins on an address divisible by 16 (such an address ends with an hex digit 0h or 0000b)
In the 8086/88, 64 K is assigned to each categoryCode segment Data segment Stack Segment Extra Segment
Advantages and disadvantages of Segmented Memory
One program can work on several different sets of data. This is done by reloading register DS to a new value.
Programs that reference logical addresses can be loaded and run anywhere in the memory: relocatable
Segmented memory introduces extra complexity in both hardware in that memory addresses require two registers.
They also require complexity in software in that programs are limited to the segment size
Programs greater than 64 KB can be run on 8086 but the software needed is more complex as it must switch to a new segment.
Protection among segments is provided.
Segment Registers
Logical and Physical Addresses
Example
16 bit Segment Register Assignments
Addressing Modes When the 8086 executes an instruction, it performs the specified function on data These data, called operands,
May be a part of the instruction May reside in one of the internal registers of the microprocessor May be stored at an address in memory
Register Addressing Mode MOV AX, BX MOV AL,BH
Immediate Addressing Mode MOV AL,15h MOV AX,2550h MOV CX,625
Direct Addressing Mode
A memory location is to be referencedEx: MOV CL,[20H] ; 8 bit transferNote the brackets around 20hEx2: MOV CX,[20H] ; 16 bit transfer
Example for Register Indirect Addressing
MOV instructionsMOV destination, source8 bit moves
MOV CL,55hMOV DL,CLMOV BH,CL
16 bit movesMOV CX,468FhMOV AX,CXMOV BP,DI
MOV Instruction
MOV instruction
ADD Instruction
Data Segment
Data Segment
Data Segment
Top Related