Lec - 7 Micro Must
Lec - 7 Micro Must
8086
MICROPROCESSORS
Lec.7
Dr. Abdallah Ramadan Fawzy
E-Mail: Abdallah.gad@must.edu.eg
The figures and text included in slides are borrowed from various books, websites, and
other sources for academic purposes only. The author do not claim any originality.
ORG 0000H ; Set the origin of the program to memory address 0000H
START: ; Label for the start of the program
MVI A, 0AH ; Load the value 0AH into register A
CPI 05H ; Compare the value in register A with 05H
JZ EQUAL ; Jump to the EQUAL label if the values are equal
JC LESS ; Jump to the LESS label if A is less than 05H
JMP GREATER ; Jump to the GREATER label if A is greater than 05H
EQUAL: ; Label for when the values are equal
MVI B, 01H ; Load the value 01H into register B
HLT ; Halt the program
LESS: ; Label for when A is less than 05H
MVI B, 02H ; Load the value 02H into register B
HLT ; Halt the program
GREATER: ; Label for when A is greater than 05H
MVI B, 03H ; Load the value 03H into register B
HLT ; Halt the program
END START ; End of the program
In this code, we start by loading the value 0AH into register A. We
then use the `CPI` instruction to compare the value in A with 05H.
If the values are equal, we jump to the `EQUAL` label. If A is less
than 05H, we jump to the `LESS` label. If A is greater than 05H, we
jump to the `GREATER` label.
We then use the `JPE` instruction to check the parity flag (P), which is set when the
result of an operation has an even number of 1s in its binary representation. If the P
flag is set, we jump to the `EVEN` label. If the P flag is not set (i.e., the result has an
odd number of 1s), we jump to the `ODD` label.
At each of these labels, we perform a different action based on the parity of the
result. For example, if the result has an even number of 1s, we load the value 01H
into register B and halt the program. If the result has an odd number of 1s, we load
the value 02H into register B and halt the program.
Note that the `JPE` instruction is typically used to check the parity of the result of an
operation, rather than the value of a register. In this example, we use the `ANI`
instruction to limit the range of values that A can hold so that we can use the `JPE`
instruction to check the parity of the result.
Interrupt is a process where an external device can
get the attention of the microprocessor.
The process starts from the I/O device
Bit 0 is the mask for RST 5.5, bit 1 is the mask for RST 6.5 and bit 2 is
the mask for RST 7.5.
If the mask bit is 0, the interrupt is available.
If the mask bit is 1, the interrupt is masked.
Bit 3 (Mask Set Enable -MSE) is an enable for setting the mask.
If it is set to 0 the mask is ignored and the old settings remain.
If it is set to 1, the new setting are applied.
The SIM instruction is used for multiple purposes and not only for
setting interrupt masks.
It is also used to control functionality such as Serial Data
Transmission.
Therefore, bit 3 is necessary to tell the microprocessor whether or
not the interrupt masks should be modified
Triggering Level
MOV Move
MVI Move Immediate
LDA Load Accumulator Directly from Memory
STA Store Accumulator Directly in Memory
LHLD Load H & L Registers Directly from Memory
SHLD Store H & L Registers Directly in Memory
Summary Data transfer
An 'X' in the name of a data transfer instruction implies that it deals with
register pair (16-bits);
Unconditional branching
JMP Jump
CALL Call
RET Return
Conditions
NZ Not Zero (Z = 0)
Z Zero (Z = 1)
NC No Carry (C = 0)
C Carry (C = 1)
PO Parity Odd (P = 0)
PE Parity Even (P = 1)
P Plus (S = 0)
M Minus (S = 1)
Conditional branching
Summary - Stack