Professional Documents
Culture Documents
3 2nd Theory
3 2nd Theory
INTERNAL ARCHITECTURE
Advance Processors
SEGMENTATION
There were also four sixteen-bit segment registers (CS, DS, SS, ES, standing for "code segment", "data segment", "stack segment" and "extra segment") that allowed the CPU to access one megabyte of memory in an unusual way. Rather than concatenating the segment register with the address register, as in most processors whose address space exceeded their register size, the 8086 shifted the segment register left 4 bits and added it to the offset address (physical address = 16segment + offset), producing a 20-bit effective address from the 32-bit segment:offset pair. As a result, each physical address could be referred to by 212 = 4096 different segment:offset pairs.
Advance Processors
FLAG REGISTERS
The Flag Register is a special register associated with the ALU. A 16-bit flag register in the EU contains nine active flags. Fig. shows the location of the nine flags in the flag register. Six flags are status flags- AF, CF, OF, SF, PF and ZF. The remaining three flags are control flags DF, IF, and TF.
CF(carry flag) : If this flag is set, there has been a carry out or overflow of the most significant
bit. It is used by instructions that add and subtract multi byte numbers.
PF (parity flag) : If this flag is set, the result has even parity, an even number of 1s. This flag
can be used to check for transmission errors.
AF (auxiliary flag) : If this flag is set, there has been a carry out or borrow of the 4 least
significant bits. This flag is used during decimal arithmetic instructions.
Advance Processors
ZF (zero flag) : If this flag is set, the result of the operation is 0. SF (sign flag) : Since negative binary numbers are represented in the 8086/8088 in standard 2s
complement notation. SF indicates the sign of the result ( 0 = positive, 1 = negative).
TF (trap flag) : Setting TF puts the processor into single-step mode for debugging. In this
mode the MPU automatically generates an internal interrupt after each instruction, allowing a program to be inspected as it executes instruction by instruction.
OF (overflow flag) : If this flag is set, an arithmetic overflow has occurred; that is , a
significant digit has been lost because the size of the result exceeded the capacity of its destination location.
Advance Processors
Advance Processors
Logical Instructions
NOT AND OR XOR TEST : Logical NOT of byte or word (one's complement) : Logical AND of byte or word : Logical OR of byte or word : Logical exclusive-OR of byte or word : Test byte or word (AND without storing)
Arithmetic Instructions
ADD, SUB ADC, SBB INC, DEC NEG CMP MUL, DIV IMUL, IDIV CBW, CWD : Add, subtract byte or word : Add, subtract byte or word and carry (borrow) : Increment, decrement byte or word : Negate byte or word (two's complement) : Compare byte or word (subtract without storing) : Multiply, divide byte or word (unsigned) : Integer multiply, divide byte or word (signed) : Convert byte to word, word to double word
Advance Processors
Transfer Instructions
JMP : Unconditional jump (short 127/8, near 32K, far between segments)
Conditional jumps:
JA (JNBE) JAE (JNB) JB (JNAE) JBE (JNA) JE (JZ) JG (JNLE) JGE (JNL) JL (JNGE) JLE (JNG) JC, JNC JO, JNO JS, JNS JNP (JPO) JP (JPE) : Jump if above (not below or equal) +127, -128 range only : Jump if above or equal(not below) +127, -128 range only : Jump if below (not above or equal) +127, -128 range only : Jump if below or equal (not above) +127, -128 range only : Jump if equal (zero) +127, -128 range only : Jump if greater (not less or equal) +127, -128 range only : Jump if greater or equal (not less) +127, -128 range only : Jump if less (not greater nor equal) +127, -128 range only : Jump if less or equal (not greater) +127, -128 range only : Jump if carry set, carry not set +127, -128 range only : Jump if overflow, no overflow +127, -128 range only : Jump if sign, no sign +127, -128 range only : Jump if no parity (parity odd) +127, -128 range only : Jump if parity (parity even) +127, -128 range only
Loop control:
LOOP LOOPE (LOOPZ) LOOPNE(LOOPNZ) JCXZ : Loop unconditional, count in CX, short jump to target add. : Loop if equal (zero), count in CX, short jump to target add. : Loop if not equal(not zero),count in CX,short jump to target add. : Jump if CX equals zero (used to skip code in loop)
Advance Processors
String Instructions
MOVS MOVSB, MOVSW CMPS SCAS LODS, STOS : Move byte or word string : Move byte, word string : Compare byte or word string : Scan byte or word string (comparing to A or AX) : Load, store byte or word string to AL or AX
Inactive states:
NOP WAIT HLT : No operation : Wait for TEST pin activity : Halt processor
Advance Processors
For programs which give output directly on computer screen : C:\tasm\> progname.exe