The document describes assembly language instructions and programming for the 8085 microprocessor. It defines instructions like INR, DCR, JMP, conditional jumps and provides examples of how to use them. It also provides examples of programs to clear data tables, copy data between tables, exchange data between tables, add 8-bit and 16-bit numbers, and add all elements of a data series stored in memory.
2. INR R
• INR R – Increment the specified register
by 1.
– R ← R + 1
– R can be any of the general purpose registers
(A, B, C, D, E, H, L).
– Affects all the flags except CY.
– Register Addressing Mode.
– 1-byte instruction and takes 1 Machine Cycle
for execution.
– E.g. INR B, INR A.
– Amounts to 7 different Opcodes.
3. DCR R
• DCR R – Decrement the specified
register by 1.
– R ← R - 1
– R can be any of the general purpose registers
(A, B, C, D, E, H, L).
– Affects all the flags except CY.
– Register Addressing Mode.
– 1-byte instruction and takes 1 Machine Cycle
for execution.
– E.g. DCR C, DCR H.
– Amounts to 7 different Opcodes.
4. INR M
• INR M – Increment the content of
memory (location specified by HL Pair)
by 1.
– ((HL)) ← ((HL)) + 1
– Affects all the flags except CY.
– Indirect Addressing Mode.
– 1-byte instruction
– Takes 3 Machine Cycles (Fetch, Read and
Write) for execution.
5. DCR M
• DCR M – Decrement the indirect byte
by 1 (memory location specified by HL
Pair).
– ((HL)) ← ((HL)) – 1
– Affects all the flags except CY.
– Indirect Addressing Mode.
– 1-byte instruction
– Takes 3 Machine Cycles (Fetch, Read and
Write) for execution.
6. JMP Instruction
• JMP – Jump (Go) to an instruction to
execute.
E.g. JMP LABEL
• This instruction is used to change the
execution sequence.
• LABEL is a symbol placed before instruction
where processor has to jump.
• E.g. JMP HERE
• Next is a simple example for understanding
JMP
7. JMP (Contd.)
• Example of JMP
:
MOV A, B
JMP HERE
LDA 2500H
DCR B
HERE: INR A
MOV B, A
:
• Symbol HERE is
address where the
instruction INR A is
stored in memory.
• Execution of JMP
HERE, skips the
execution of LDA &
DCR in program.
8. JMP (Contd.)
• JMP ADDRESS – Jump (Go) to
ADDRESS to execute an instruction.
• ADDRESS is actually the memory address
where instruction INR A (Last Slide) is stored
in memory.
• E.g. JMP 5000H
• PCH ← 50H and PCL ← 00H, finally PC=5000H,
showing address of instruction to be executed.
• It takes 3 Machine Cycles for execution.
• Execution of JMP is shown next.
9. Conditional JMPs
• JZ – Jump (Go) to instruction to execute
if ZF=1.
E.g. JZ ADDRESS (Memory Address)
• Executes similar to JMP but checks ZF before jump. If
ZF=1 then jump otherwise don’t jump.
• JNZ– Jump (Go) to instruction to execute
if ZF=0.
E.g. JNZ ADDRESS (Memory Address)
• Executes similar to JZ but checks for ZF=0 before
jump. If ZF=0 then jump otherwise don’t jump.
10. Conditional JMPs (Contd.)
• Example of JZ
MVI A, 01
DCR A
JZ HERE
STAX D
DCR B
HERE: INR D
MOV C, A
:
• DCR A sets ZF=1.
• So JZ HERE makes a
jump.
• Execution of JZ
HERE, skips the
execution of STAX &
DCR in program.
11. Conditional JMPs (Contd.)
• Example of JZ
MVI A, 01
INR A
JZ HERE
STAX D
DCR B
HERE: INR D
MOV C, A
:
• INR A, sets ZF=0.
• So, JZ HERE does
not make a jump.
• Hence, STAX D and
DCR B is executed
next and so on.
12. Conditional JMPs (Contd.)
– JPE Jump on EVEN Parity
or Jump if Parity is SET
i.e. Jump on PF = 1.
– JPO Jump on ODD Parity
or Jump if Parity is NOT SET
i.e. Jump on PF = 0.
– JM Jump if Result is Minus (Negative)
i.e. Jump on SF = 1.
– JP Jump if Result is Positive
i.e. Jump on SF = 0
13. Conditional JMPs (Contd.)
– JC Jump if a Carry Generated
i.e. Jump on CF = 1.
– JNC Jump if Carry Not Generated
i.e. Jump on CF = 0.
14. A Simple Program (P6)
A data table containing 10 elements is
stored at memory location 2050H.
Write an 8085 ALP that will store 00 at
all the data positions.
15. Physical
Address
Data SYMBOL
2050H XX TABLE
2051H XX
2052H XX
2053H XX
2054H XX
2055H XX
2056H XX
2057H XX
2058H XX
2059H XX
Data Table (Program P6)
Base Address of TABLE
16. Program P6 (Contd.)
HL ← Base Address of TABLE
C ← Data Count (0AH)
A ← 00, Data to store
Increment Memory Pointer
i.e. HL ← HL +1
Decrement the data counter
i.e. C ← C - 1
All Data
Cleared?
N
Y
STOP
Store data into TABLE
i.e. ((HL)) ← A
17. Program P6 (Contd.)
START: LXI H, TABLE ; Initialize Memory Pointer.
MVI C, COUNT ; Init. Data Counter (0AH).
MVI A, 00 ; Clear Accumulator.
AGAIN: MOV M, A ; Clear memory using Acc.
INX H ; Point to Next Data
DCR C ; Decrement Count by 1
JNZ AGAIN ; All Data cleared?
; ‘NO’, Go back to clear again
HLT ; ‘YES’, STOP
18. Alternate Program P6 (Contd.)
START: LXI H, TABLE ; Initialize Memory Ptr.
MVI C, COUNT ; Init. Data Counter (0A)
AGAIN: MVI M, 00 ; Clear memory.
INX H ; Point to Next Data
DCR C ; Decrement Count by 1
JNZ AGAIN ; All Data cleared?
; ‘NO’, Go back to clear again
HLT ; ‘YES’, STOP
19. A Different Organization of Data Table
• First Location tells how
many data are there in
the given table.
• Program should use this
fact as the data starts
from next location.
• Write program to
clear this table.
Address Data Comments
2600 0AH DATA COUNT
2601 XX
2602 XX
2603 XX
2604 XX
2605 XX
2606 XX
2607 XX
2608 XX
2609 XX
260A XX
20. Program P6 (Contd.)
HL ← Base Address of TABLE
A ← 00, Data to store
Store data into TABLE
i.e. ((HL)) ← A
Decrement the data counter
i.e. C ← C - 1
All Data
Cleared?
N
Y
STOP
Increment Memory Pointer
i.e. HL ← HL +1
Store count into C
i.e. C ← ((HL))
21. Alternate Program P6 (Contd.)
START: LXI H, TABLE ; Initialize Memory Pointer.
MVI A, 00 ; Clear Accumulator.
MOV C, M ; Init. Data Counter (0AH).
AGAIN: INX H ; Point to Next Data location.
MOV M, A ; Clear memory using Acc.
DCR C ; Decrement Count by 1
JNZ AGAIN ; All Data cleared?
; ‘NO’, Go back to clear again
HLT ; ‘YES’, STOP
22. A data table containing 10 data items,
named TABLE1, is stored in memory.
Write an 8085 ALP to copy data from
TABLE1 to another table, namely
TABLE2.
Program (P7)
23. Data Table (P7)
Address Data Comments
2400 91H DATA1
2401 28H DATA2
: : :
: : :
2409 44H DATA10
: : :
: : :
2450 XX DATA1
: : :
2459 XX DATA10
Base Address of TABLE1
Base Address of TABLE2
24. Program P7 (Contd.)
HL ← Base Address of TABLE1
DE ← Base Address of TABLE2
C ← Data Count (0AH)
Get data from TABLE1
i.e. A ← ((HL))
Increment Memory Pointers
i.e. HL ← HL +1
DE ← DE + 1
Decrement the data counter
All Data
Copied?
N
Y
STOP
Store data into TABLE2
i.e. ((DE)) ← A
25. Program P7 (Contd.)
START: LXI H, TABLE1 ; Initialize TABLE1 Pointer.
LXI D, TABLE2 ; Initialize TABLE2 Pointer.
MVI C, 0AH ; Initialize Data Counter.
AGAIN: MOV A, M ; Get TABLE1 Data.
STAX D ; Store at TABLE2.
INX H ; Point to Next Data location.
INX D
DCR C ; Decrement Count by 1.
JNZ AGAIN ; All Data copied?
; ‘NO’, Go back to copy again
HLT ; ‘YES’, STOP
26. Two data tables containing 10 data
items, named TABLE1 and TABLE2, are
stored in memory. Write an 8085 ALP to
exchange the data of two tables.
Program (P8)
27. Data Table (P8)
Address Data Comments
2400 91H DATA1
2401 28H DATA2
: : :
: : :
2409 44H DATA10
: : :
: : :
2450 20H DATA1
: : :
2459 6AH DATA10
Base Address of TABLE1
Base Address of TABLE2
28. Program P8 (Contd.)
START: LXI H, TABLE1 ; Initialize TABLE1 Pointer.
LXI D, TABLE2 ; Initialize TABLE2 Pointer.
MVI C, 0AH ; Initialize Data Counter.
AGAIN: MOV B, M ; TABLE1 Data in B.
LDAX D ; TABLE2 Data in A.
MOV M, A ; Store TABLE2 Data at TABLE1.
MOV A, B ; TABLE1 Data in A.
STAX D ; Store TABLE1 Data at TABLE2.
INX H ; Point to Next Data location.
INX D
DCR C ; Decrement Count by 1.
JNZ AGAIN ; All Data copied?
; ‘NO’, Go back to copy again
HLT ; ‘YES’, STOP
29. Alternate Program P8
START: LXI H, TABLE1 ; Initialize TABLE1 Pointer.
LXI D, TABLE2 ; Initialize TABLE2 Pointer.
MVI C, 0AH ; Initialize Data Counter.
AGAIN: MOV B, M ; TABLE1 Data in B.
LDAX D ; TABLE2 Data in A.
XCGH ; Exchange the pointers.
MOV M, B ; TABLE1 Data at TABLE2.
STAX D ; Store TABLE2 Data at TABLE1.
XCHG ; Restore the pointers
INX H ; Point to Next Data location.
INX D
DCR C ; Decrement Count by 1.
JNZ AGAIN ; All Data copied? ‘NO’, Go back.
HLT ; ‘YES’, STOP
30. Program (P10)
Write an 8085 ALP to add two 8-bit numbers and result may
be 16-bit. Assuming data are stored in memory at locations
2500H and 2501H.
MVI C, 00 ; Initialize Carry Counter
LDA 2500H
MOV B, A ; Get DATA1 in B.
LDA 2501H ; Get DATA2 in A.
ADD B ; Add DATA1 and DATA2.
JNC DN1 ; Is CY=0? ‘YES’ Go to DN1.
INR C ; ‘NO’ Increment carry counter by 1.
DN1: STA 2502H ; Store the low byte of result in memory.
MOV A, C ; Get high byte of result in in A.
STA 2503H ; Store the high byte of result in memory.
HLT ; Stop
31. Alternate Program (P10)
MVI C, 00 ; Initialize Carry counter.
LXI H, 2500H ; Pointer to first data in memory.
MOV A, M ; Get DATA1 in A.
INX H ; Increment pointer to DATA2.
ADD M ; Add DATA1 and DATA2.
JNC DN1 ; Is CY=0? ‘YES’ Go to DN1.
INR C ; ‘NO’ Increment carry counter by 1.
DN1: INX H ; Increment Ptr to store low byte of result.
MOV M, A ; Store the low byte of result in memory.
INX H ; Increment Ptr to store high byte of result
MOV M, C ; Store the high byte of result in memory.
HLT ; Stop
32. Program (P11)
A data series of
integers is stored in
memory, as shown.
Write an 8085 ALP that
will add all the
elements of this series
and store the result in
memory. Result may
be 16-bit.
Address Data Comments
2500 09H ELEMENT
COUNT
2501 10H ELEMENT 1
2502 19H ELEMENT 2
2503 25H
2504 01H
2505 E1H
2506 11H
2507 06H
2508 00H
2509 F0H ELEMENT 9
33. Program (P11) (Contd.)
LXI H, 2500H ; Pointer to data series.
MOV B, M ; Get Element Count in B.
MVI C, 00 ; Initialize Carry counter.
MVI A, 00 ; Initial Sum=00 in A
NEXT: INX H ; Pointer to next data in series.
ADD M ; Add next element to previous sum.
JNC DN1 ; Is CY=0? ‘YES’ Go to DN1.
INR C ; ‘NO’ Increment carry counter by 1.
DN1: DCR B ; Decrement Element Counter.
JNZ NEXT ; All elements added? ‘NO’ Go back.
; ‘YES’ Store the result …..contd.
34. Program (P11) (Contd.)
INX H ; Pointer to store low byte of result.
MOV M, A ; Store the low byte of result.
INX H ; Pointer to store high byte of result.
MOV M, C ; Store the high byte of result.
HLT ; Stop