Professional Documents
Culture Documents
Insem Part-2 MMTP
Insem Part-2 MMTP
np-1lop and enters into an Interrupt Acknowledge (INA) machine cycle. The INA cycle and OP
sends out a RD, INA sends
ycle are identical except for two differences which are: () While OF
while in OF, I0/M 0. (In INA, =
out anINTA (on the ÎNT pin); (i) During INA, IO/M 1, =
INTR.
MINA) M2(INA)
M2MR)
SIGNALS
T4TT6 TI T2 T3
T2T3TI12 13
CLOCK
INTR
NTA
PCH PCH
A8-A15 (PC1)H
OUT IN OUT
N
ADO-AD7
(raLo.eA PCL DO-p7(E
ALE
RD
WR
30
THE 8085A CPU
SIGNAL M3 (INA) M4 (MW) MS (MW) Mi (OF)
TiT2 T3 TIT2T3 TiT2T3 TiT2
CLOCK
INTR
INTA
oMS1,S0 X K1, 1, 1 0, 0, 1 0, 0, 1X 0, 1, 1
A8-A15 PCH (B3)
PCL (SP-1) H (SP-2) H
OUT
OUT oUT OUT oUT OUT
ADO-AD7
ALE
RD
WR
Figure 3.10b 8085A Interrupt Acknowledge Machine Cycles (Contd.)
(Source: Intel Corporation)
If it is a CALL routine, then it is necessary to fetch the two bytes of the CALL address
the
through two INA machine cycles (M2 and M3 in the diagram). It is also necessary to save
address of the main program the CPU was handling when the interrupt appeared. This is done
bus
by storing the contents of the PC onto the Stack, executed by placing first SP-1 on the address
and storing the high-order byte of the PC (PCH), then placing SP-2 on the address bus and
storing the low-order byte of the PC. (PCL). In the next machine cycle (which would be OF) the
address of the CALL subroutine is placed on the address bus (B3 the high-order byte on A8-
A15, and B2- the low-order byte on ADO-AD7), which would result in the CALL subroutine to
be executed.
The CPU inhibits incrementing of the PC during the INA cycles so that the correct PC can
be stored onto the Stack during M4 and M5.
3.3.5 Bus Idle (BI) and Halt State
There could a few situations when the machine cycles are neither READ nor WRITE, such as
(i) To execute the DAD instruction (this instruction adds the contents of a specified register pair
to the contents of H and L) ten T-states are needed. Rather then having M1 of ten clock
cycles, it generates the extra machine cycles which do not involve either memory or 1/0.
31
INTRODUCTION TO MICROPROCESSORS
IDLE eycles
these BUS
case of DAD,
machine cycles. In the ALE is not
These are called BUS IDLE (B) low ever and
does not go
difference is that RD
are identical to MR cycle. The M3 cycles of DAD.
during M2 and
generated. Further, READY is ignored or TRAP
internal opcode generation
for the RST
also appears during trigger at the
The rising edge
(ii) BUS DLE cycle illustrated for RST 7.5
in Fig. 3.11. of the last but
one
interrupts; the cycles are on the falling edge
that is sampled but without
sets an internal latch (identical to OF
KST 7.5 input then enters a BUS
IDLE machine cycle
RESTART instruction,
putting
clock period. The CPU is own
generates Program
causing the RD to go low)
during which it address of RST
7.5) on to the
003CH (vector executed. During
the
PC onto the Stack and placing 7.5 can be
the (ISR) of RST
routine
so that the interrupt service
Counter
BI cycle the READY line is ignored.
MI (B)
M2 (MW)
SIGNALS
MI(OF)
Ti T2
T3 T4 TS T6 TIT2
T3 T4
CLOCK
RST 7.5
1O/M
S1, So
SP H
A8-A15 CPC-1H PCH
OUT
IN
N
(SP-13LPCH
ADO-AD7 L
ALE
ÎNTA
RD
WR
RBADY
Figure 3.11 Bus läle Machine Cycle For RST 7.5
(Source: Intel Corporation)
The BUS DLE state entered during a HALT state with the RST 7.5 triggered is shown in
Fig. 3.12. In M2, the CPU is in THLT the dashed lines indicate the floating signals. Appearence
ofa valid interrupt can cause the processor to exit the TuT State. The CPU resets the INTE FF,
this disables permanently further interrupts and moves to the T1 state
(T1.M1) of the next
instruction. (The HOLD input makes the CPU exit THALT
beyond which it returns to THALT).
temporarily for the duration of the THOLD
32
THE 8085A CPU
Mi (OF) M2 (HALT)
SIGNALS
T3 T4 Mi( M2 (MW)
T1THAr THALT T1T2T3 T4 TS T6 TI
CLOCK
RST 7.5
oM
S1,
A&-A1S
(ciH CH PCH (SP1
N OUT IN
OUT OUT
ADO-AD7 HALT PO
ALE
INTA
RD
RRADY
Figure 3.12 Halt and Bus Idle cycles with RST 7.5 terminating THALT State
Source: Intel Corporation)
In Fig. 3.12 the rising edge of RST 7.5 trigger sets an internal latch that is sampled during CLK
1 of every TrALT State (besides during a high clock occurring two clock cycles before any M1.T1).
Thelatched interrupt high (due to INTE FF = 1 or RST 7.5 mask 0) forces the CPU to exit
THALT State at the end of the following clock period and to enter Mi.T1.
3.3.6 Hold and Halt States
When the CPU is in THOLD State, it relinquishes the bus; in this situation external devices can gain
control of the bus and the bus can be used for DMA, for example.
As regards THOLD and THALT states, three situations can occur:
) The CPU is in TaAr state:
During CLK = 1 of every TrALT state the processor internally latches, (a) The state of the
HOLD line, and (b) Any unmasked interrupts. If the HOLD is high, then on the following
CLK 1, the CPU exits THALT and enters THoLD This takes place even if a valid interrupt
appears simultaneously with the HOLD signal.
33
INTRODUCTION TO MICROPROCESSORS
or TwAT) or the
last state before T5
= 1 of the last state before T3 (T2
Then during CLK the HOLD line.
(T4 of a six T-state M1) the CPU latches internally
CPU enters
in the following CLK, the
the next CLK 1, the HOLD is high, then
Ifduring
THOLD
latches the
state before each M1.T1, internally
The CPU, during the clock of the last but one
state of any unmasked interrupt.
Due to its internal constraints, on POWER ON, when the Vcc terminal of 8085A reaches 4.75V
level, the device takes at least another 10 ms to perform satisfactorily. To circumvent any problem
due to this eonstraint, it is suggested that the RESET IN pin be kept low during this period. A
simple cireuit which achieves this satisfactorily is given below:
Vcc
MANUAL RESET
RESET IN
input. The CPU recognises, only during the CLK 1 of the next T state, presence of
RESET IN signal. f RESET IN is found low, the CPU then outputs RESET OUT any and1atcned
=
enters
TRESET during the next T state. It is recommended that the RESET ÎN be kept low for a minimum
of three clock periods for necessary synchronisation after which the RESETN could be allowed
to go high.Then the CPU enters M1.TI during the next T1 state, and with PC 0000H, it starts
executing instruction_, with the interrupt system masked, from 0000HA
The timing relationship between SID sigmal, and execution of RIM (which loads SID signal to bit
D7 of the Accumulator) is shown in Fig. 3.13. During T3.CLK = 0 of the RIM instruction, the
status of the SID is internally latched. The figure also shows the relationship of SIM (which loads
bit D7 of the Accumulator signal to SOD, provided bit 6 is 1) with the SOD signal. The transfer
takes place during Mi.T2. CLK = 0 of the instruction that follows SIM or RIM.
SOD
SID
ACCUMULATOR
(BT 7)
A8-A1S
ALB
RD
35
CHAPTER 4
two, and
1. The 8085A Instruction Set consists of one-,
is always the
three-byte instructions. The first byte
the second byte is
opcode; in two-byte instructions
instructions the last two
usually data; in three-byte
address.
bytes represent some
into five
2. The Instruction Set can be categorised
of functions the
different groups based on the nature
Transfer group (i)
instructions carry out; (i) Data
Arithmetic group, ( ) Branch group, (iv) Logic group,
Machine Control
and (v) Stack, Input/Output, and
group.
data
3. The Data Transfer group instructions load given
into registers, move data between registers, and move
data between registers and memory locations. The
Arithmetic group instructions add, subtract, increment
or decrement data in registers or in memory.
In
addition, there is one instruction in which eight-bit
data is adjusted to form BCD digits. The Branch group
instructions include calling of subroutines, conditional
and unconditional jumps, returns, and restarts. The
Logic group instructions perform logie operations such
as AND, OR, and XOR, compare data between
registers, or between register and memory, rotate or
complement data in registers. The Stack, Input/Output
Machine Control group instructions transfer data
and
between registers and the Stack, exchange contents of
SP and HL with Stack Top, move data to and from
specific Input/Output ports, enable or disable
Interrupts, and handle Interrupt masking.
B C D E
Exampie: 1CH is the Opcode for INR E. CIH is the Opcode for POPB.
37
INTRODUCTION TO MICROPROCESSORS
The 8085A instructions are presented below in terms of their functional grouping:
MVI r,data
MVI M,data
MOV r1,12
MOV M,r
MOV r,M
LXI rp,data
STA addr
LDA addr
SHLD addr
LHLD addr
LDAX rp
STAX rp
XCHG
This instruction directly loads a single register with a single byte of data that follows the opcode.
This instruction directly stores the data that follows the opcode in the memory location specifñed
by the contents of the H and L registers.
This instruction transfers data from the source register to an address which is pointed to by H
and L registers.
In the description of instructions, r represents a register, rp a register pair, and addr an address.
38
THE 8085A INSTRUCTiON SET
MOV r,M (Move data from location specified by H and L registers to register r)
This instruction transfers data from a location whose address is in H and L registers to the
destination register r.
LXI p,data (Load immediate register pair with double byte data)
This instruction loads immediately the double byte 16-bit data into a register pair or into the SP
register. The register pair may be BC, DE or HL
STA addr (Store data from A direct at the address that follows)
This stores in the memory the contents of the Aceumulator in the address that is specifid.
LDA addr (Load data into A direct from the address that follows)
This instruction copies the contents of the memory location given by the address onto the
Accumulator.
The contents of the register L is stored in the memory location corresponding to the address given,
and the contents of the register H at the next address location.
This instruction copies the contents of the memory location given by the address onto the register
the register H.
L and the contents of the next address location onto
LDAX p (Load A with the contents of the memory location whose address is in rp)
39
INTRODUCTION TO MICROPROCESSORS
of L with that of E.
s nstruction exchanges the contents of the register H with that of D, and
INR r
INR M
INX rp
DCR r
DCR M
DCX rp
The contents of the specified register are decremented by one. All flags except Carry are affected.
40
3325
THE 8085A
INSTRUCTION SET
DCX p (Decrement register pair)
4.2.2 Add
The contents of the specified register are added to the contents of the Accumulator. The result is
stored in the Accumulator. All flags are affected.
The contents of the memory location whose address is in HL are added to the Accumulator. All
flags are affected.
The data given is added to the contents of the Accumulator. The result is stored in the
Accumulator. All flags are affected.
If the Carry flag is set by some previous operation, it adds 1 and the contents of
register r to A,
else it adds the contents of r only. The result remains in the Accumulator. All
fagsare affected.
ADC M (Add data in memory to A with Car1y)
If the Carry flag is set by some previous operation, it adds 1 and the contents of
the memory
location whose address is in HL to A, else it adds the memory contents
only. The result remains
in the Accumulator. All flags are affected.
41
I N T R O D U C T I O N T O M I C R O P R O C E S s O R S
with carry)
ACI data (Add immediate data to A dat.
adds only the given ata.
data to A, else it
1 and the given
flag is set, then it adds aifected.
All flags are
in A.
h e Carryremains
The result
H and L)
DAD p (Add register pair rp to
the specified register pair
is added
contents of
could be BC, DE, HL or SP. The affected.
The register pair is
the Carry flag
remains in HL. Only
to H and L The result
4.2.3 Subtract
set of instructions:
This group consists of the following
SUBr
SUB M
SUI data
SBBr
SBB M
SBI data
The contents of the specified register are subtracted from A. IfA is less than r, the Carry (Borrow)
lag is set. The result remains in A. All flags are affected.
The given data is subtracted from A with borrow. If the Carry flag is set by some
operation, then 1 plus the data are subtracted from A, else only the given data is subtracted
previrom
A, The result remains in A. All are
flags affected.
This adjusts A to packed BCD (Binary Coded Decimal) after addition of two BCDs. It functions
in two steps:
1. f the lower 4-bits of A are greater than 9 or the Auxiliary Carry flag is set, then it adds 06H
to A
2. Subsequently, if the higher 4-bits of A are now greater than 9 or the Carry flag is set, it adds
60H to A. This affects all flags.
4.3.1 Jump
JMP addr
Jcond addr
PCHL
This loads the PC with the address given, and resumes the program execution from this location.
INTRODUCTION TO MICROPROCESSORS
Jeond addr (Jump conditionally to the address given)
nis instruction causes a jump to the given address if a specified condition is satisfied. The
conditions could be
JC Jump on Carry C-1
JNC Jump on not Carry C-0
JP Jump on Positive S=0
JM Jump on Minus 1
JPE Jump on Parity even P-1
JPO Jump on Parity odd P-0
JZ Jump on Zero Z-1
JNZ Jump on not Zero Z-0
4.3.2 Call
CALL addr
Ccond. addr
This pushes the current PC contents onto the Stack and loads the given address onto the PC;
thus, the CPU jumps to the given address. The Stack Pointer is decremented by two.
This instruction Calls the subroutine at the given address if a specified condition is satisfied. The
Stack Pointer is decremented by two. The following conditional Calls can be made:
CC Call on Carry C 1
CNC Call on not Carry C-0
CP Call on Positive S-0
CM Call on Minus S-1
CPE Call on Parity even P-1
44
THE 8085A
INSTRUCTION SET
CPO Call on Parity odd
CZ Call on Zero
P-0
Z-1
CNZ Call on not Zero
Z-0
4.3.3 Return
4.3.4 Restart
This instruction transfers the control to the specific memory addresses as listed below. This
instruction is equivalent to a fixed address CALL instruction. All RST instructions save the
current Program Counter at the top of the Stack. The Stack Pointer is decremented by two. The
destination address is eight times n (in hexadecimal).
45
INTRODUCTION TO MICROPROCESSORS
RST 0 C7 0000
RST 1 CF 0008
RST 2 D7 0010
RST 3 DF 0018
RST 4 E7 0020
RST 5 EF 0028
RST 6 F7 0030
RST 7 FF 0038
ANAr
ANA M
ANI data
XRAr
XRA M
XRI data
ORA r
ORA M
ORI data
CMP r
CMP M
CPI data
STC
CMC
CMA
This instruction logically ANDs the contents of the specified register with those of the
A.ceumulator bit by bit and places the result in the Accumulator. The Carry flag is cleared and the
Auxiliary Carry flag is set. All flags are affected.
This instructuion logically ANDs the contents of the memory location whose address is in HL with
by result Aceumulator. The Carry flag is
those of the Aceumulator bit bit and places the
cleared and the Auxiliary Carry flag is set. All flags are affected.
in the
46
THE 8085A
INSTRUCTIiON SET
ANI data (AND Immediate with A)
This instruction performs an Exclusive OR operation bit by bit between the contents of the
Accumulator and the 8-bit data that is given. The result is stored in the Accumulator. All fags
are affected. Both the Carry and Auxiliary Carry flags are cleared.
with A)
ORI data (OR Immediate data
between the contents of the Accumulator
and
This instruction performs a bit by bit OR operation affected. Both
in the Accumulator. All flags are
The result is stored
the 8-bit data that is given.
are cleared.
the Carry and Auxiliary Carry flags
47
MICROPROCESSORS
RAL
CY MSB LSB
RAR
CY
LSB
MSB
RLC, RRC are equivalent to 8-bit rotate, and RAL, RAR are equivalent to 9-bit rotate instructions.
PUSH rpP
PUSH PSW
POP rp
POP PSWW
XTHL
SPHL
The register pair could be BC, DE, or HL. As a result of the PUSH operation, SP is decremented
and the high-order byte of rp is copied onto the location pointed to by SP; SP is again decremented
the low-order byte of rp is copied onto the location pointed to by SP. None of the lags are
affected
50
THE 8085A INSTRUCTION SET
PUSH PSW (Push Processor Status Word onto Stack)
PSW is the Program Status Word; it consists of the Accumulator and Flag registers with
Accumulator as the high-order byte. As a result of the PUSH operation, SP is decremented and
the high-orderbyte (A) is copied onto the location pointed to by SP; SP is again decremented and
the low-order byte (Flag register) is copied onto the locatio to by SP. None of the flags
are affected.
pointe
to by SP
The register pair could be BC, DE, or HL. It copies the contents of the location pointed
of rp, increments SP, and copies the contents of the location pointed t
onto the low-order byte
by SP onto the high-order byte of rp. None of the flags are affected.
order byte of the PSW (A). All the flags are affected.
and
of the Stack location pointed to by the SP,
The contents of L are exchanged with the contents contents
at the next Stack location (SP+1). The
the contents of H are exchanged with the contents
of the flags are affected.
of Stack Pointer register are not altered. None
4.5.2 Input/Output
IN addr
OUT addr
51
INTRODUCTION TO MICROPROCESSORS
IN addr lnput)
EI
DI
NOP
HLT
SIM
RIM
EI (Enable interrupts)
This instruction sets the interrupt enable flip-flop. The interrupts are enabled following the
execution of the next instruction.
DI (Disable interrupts)
This instruction resets the interrupt enable flip-lop. The interrupts are disabled immediately
following the execution of this instruction. An interrupt occurring during the execution of this
instruction is not recogmised.
52
THE 8086A INSTRUCTION SET
D D DD DD2 Do
D D DsD.D D D Do
53
INTRODUCTION TO MICROPROCESSORS
ANA r IN port
MOV 1,2 ADD r JMP addr Out Port
JMP Cond addr ANA M
MOV Mr ADD M XTHL
CALL addr ANI data
MOV r,M ADI data SPHL
CALL Cond addr ORA r
MVI r,data ADC r
ORA M
MVI M,data ADC M RET
RET Cond ORI data
ACI data
XRA r
LXI rp,data DAA PCHL PUSH Ip (NSP)
XRA M
SUB RST n PUSH PSw
XRI data
STA addr SUB M POP p (NSP)
LDA addr SUI data POP PSW (AFL)
CMP r
SBBr
CMP M
STAX p SBB M
CPI data
LDAX rp SBI data NOP
HLT
LHLD addr INR r (NCY)
SHLD addr INR M (NCY) CMA (NFL)
EI
DCR r (NCY)
RLC (CY) DI
XCHG DCR M (NCY)
RRC (CY RIM
RAL (CY) SIM
INX rp (NFL)
DCX rp (NFL) RAR (CY
STC (CY)
DAD rp (CY) CMC (CY)D
Source: AJ
=
= BC, DE
=
A , B, C, D, E, H, L; rp BC, DE, HL, SP;Allrp'but
Borrow; NCY = Carry; NFL No Flags
Auxiliary Carry # Auxiliary =
=
CY Only Carry; NSP Except SP; AFL All Flags