Software Model of 8086 Microprocessor
Software Model of 8086 Microprocessor
Software Model of 8086 Microprocessor
1. The 8088 microcomputer supports 1 Mbytes of external memory. 2. The memory of an 8088-based microcomputer is organized as 8-bit bytes, not as 16-bit words.
Even- or odd-addressed word/ Aligned word or misaligned word If the least significant bit of the address is 0, the word is said to be held at an even-addressed boundary.
Double word
A double word corresponds to four consecutive bytes of data stored in memory.
A pointer is a double word. The higher address word represents the segment base address The lower address word represents the offset.
Example: Segment base address = 3B4C16 = 00111011010011002 Offset value = 006516 = 00000000011001012
EXAMPLE: How should the pointer with segment base address equal to A00016 and offset address 55FF16 be stored at an even-address boundary starting at 0000816? Is the double word aligned or misaligned?
Solution: Storage of the two-word pointer requires four consecutive byte locations in memory, starting at address 0000816. The least-significant byte of the offset is stored at address 0000816 and is shown as FF16 in the previous figure. The most significant byte of the offset, 5516, is stored at address 0000916. These two bytes are followed by the least significant byte of the segment base address, 0016, at address 0000A16. Its most significant byte, A016, at address 0000B16. Since the double word is stored in memory starting at address 0000816, it is aligned
Data Types
Integer data type Unsigned or signed integer Byte-wide or word-wide integer. The most significant bit of a signed integer is a sign bit. A zero in this bit position identifies a positive number.
The range of a signed byte integer is +127 ~ -128. The range of a signed word integer is +32767 ~ -32768. The 8088 always expresses negative numbers in 2scomplement.
EXAMPLE: A signed word integer equals FEFF16. What decimal number does it represent? Solution: FEFF16 = 11111110111111112 The most significant bit is 1, the number is negative and is in 2s complement form. Converting to its binary equivalent by subtracting 1 from the least significant bit Then complement all bits give: FEFF16 = -00000001000000012 = -257
The 8088 can also process data that is coded as binarycoded decimal (BCD) numbers. BCD data can be stored in packed or unpacked forms.
1. EXAMPLE: The packed BCD data stored at byte address 0100016 equals 100100012. What is the two digit decimal number? Solution: Writing the value 100100012 as separate BCD digits gives 100100012 = 1001BCD0001BCD = 9110 2. EXAMPLE: Byte addresses 0110016 through 0110416 contain the ASCII data 01000001, 01010011, 01000011, 01001001, and 01001001, respectively. What do the data stand for? 3. Solution: Using the ASCII table, the data are converted to ASCII code: (01100H) = 010000012 = A (01101H) = 010100112 = S (01102H) = 010000112 = C (01103H) = 010010012 = I (01104H) = 010010012 = I
The addresses of the active segments are stored in the four internal segment registers: CS, SS, DS, ES.
Four segments give a maximum of 256Kbytes of active memory. Code segment 64K Stack 64K Data storage 128K (Data+Extra) The base address of a segment must reside on a 16-byte address boundary. User accessible segments can be set up to be contiguous, adjacent, disjointed, or even overlapping.
Data Registers
Data registers are used for temporary storage of frequently used intermediate results. The contents of the data registers can be read, loaded, or modified through software. The four data registers are: Accumulator register, A Base register, B Counter register, C Data register, D Each register can be accessed either as a whole (16 bits) for word data or as 8-bit data for byte-wide operation.
Status Register
The status register, also called the flags register, indicate conditions that are produced as the result of executing an instruction. Only nine bits of the register are implemented. Six of these bits represent status flags The other three bits represent control flags The 8088 provides instructions within its instruction set that are able to use these flags to alter the sequence in which the program is executed. Status and control bits maintained in the flags register Generally Set and Tested Individually 9 1-bit flags in 8086; 7 are unused.
Status flags indicate current processor status. CF Carry Flag OF Overflow Flag ZF Zero Flag SF Sign Flag PF Parity Flag AF Auxiliary Carry Arithmetic Carry/Borrow Arithmetic Overflow Zero Result; Equal Compare Negative Result; NonEqual Compare Even Number of 1 bits Used with BCD Arithmetic. Control flags influence the 8086 during execution phase DF Direction Flag IF Interrupt Flag Auto Increment/Decrement used for string operations Enables Interrupts allows fetch-execute to be interrupted TF Trap Flag Allows Single-Step for debugging; causes interrupt after each operation.
A logical address in the 8088 microcomputer system is described by a segment base and an offset. The physical addresses that are used to access memory are 20 bits in length. The generation of the physical address involves combining a 16-bit offset value that is located in the instruction pointer, a base pointer, an index register, or a pointer register and a 16-bit segment base value that is located in one of the segment register.
EXAMPLE: What would be the offset required to map to physical address location 002C316 if the contents of the corresponding segment register are 002A16? Solution: The offset value can be obtained by shifting the contents of the segment of the segment register left by four bit positions and then subtracting from the physical address. Shifting left give 002A016 Now subtracting, we get the value of the offset: 002C316 002A016 = 002316
The Stack
The stack is implemented for temporary storage of information such as data or addresses. The stack is 64KBytes long and is organized from a software point of view as 32K words. The contents of the SP and BP registers are used as offsets into the stack segment memory while the segment base value is in the SS register. Push instructions (PUSH) and pop instructions (POP) Top of the stack (TOS) and bottom of the stack (BOS) The 8088 can push word-wide data and address information onto the stack from registers or memory. Many stacks can exist but only one is active at a time.
EXAMPLE: Push operation BOS = 0105016 +FFFE16 = 0110416 TOS = 0105016 +000816 = 0105816