8085 Microprocessor Practical Guide
8085 Microprocessor Practical Guide
PAPER II
C S I I P r a c t i c a l H a n d b o o k P a g e 1 | 34
INDEX - Computer Science [Paper – II]
Sr TITLE Page
No No
01. Introduction to microprocessor
02. 8085 microprocessor & instruction set
03. Addition of two 8-bit numbers.
04. Addition of two 8 bit BCD numbers.
05. Write a program to subtract two numbers.
06 Program to exchange the contents of two blocks stored in different
memory Locations.
C S I I P r a c t i c a l H a n d b o o k P a g e 2 | 34
Microprocessor
Microprocessor is a multipurpose, programmable device that accepts digital data as input,
processes it according to instructions stored in its memory, and provides results as output.
Microprocessors use three steps commonly called Fetch, Decode, and Execute. In the Fetch step,
an instruction is copied from the memory of the computer into the microprocessor. In the Decode
step, the microprocessor figures out what operation the instruction is meant to do. In the
Execute step, this operation is performed.
Mnemonics is a set of binary code/instruction that the CPU understands. Based on the CPU, the
instruction can be one byte, two bytes or longer.1byte=8 bits. The instruction code is
usually followed by one or two operands.
Mnemonics example: -
Instruction operand operand
Code 1 2
MOV A, B
The above instruction moves the value of register B to the specified register A. (register is a
special memory located inside the CPU, where data can be stored on which arithmetic operations
can be performed).
The 8085 µp is an 8-bit microprocessor introduced by Intel in [Link] has 8-bit data bus and 16-
bit address bus. It is a 40-pin DIP chip designed using NMOS. It operates with a power supply of
+5 volts and GND. It operates at 3.2 MHZ single phase clock. 8085 generates the clock signal internally
by dividing the external supplied clock signal by two. It has 16-bit address bus and hence can
address up to 216 = 65536 bytes (64KB) memory locations.
C S I I P r a c t i c a l H a n d b o o k P a g e 3 | 34
Functional block diagram or architectures of 8085 µp.
Address Bus:
Data Bus:
The data bus is a group of eight lines used for data flow.
These lines are bi-directional, data flow in both directions between the µp and memory and
peripheral devices.
The largest number that can appear on the data bus is 11111111.
Control Bus:
The control bus carries synchronization signals and providing timing signals.
The µp generates specific control signals for every operation it performs. These signals are
used to identify a device type with which the µp wants to communicate.
C S I I P r a c t i c a l H a n d b o o k P a g e 4 | 34
Registers of 8085
The 8085 have six general-purpose registers to store 8-bit data during program execution.
These registers are identified as B, C, D, E, H, and L.
They can be combined as register pairs-BC, DE, and HL to perform some 16-bit operations.
Accumulator (A):
The accumulator is an 8-bit register that is part of the arithmetic/logic unit (ALU).
This register is used to store 8-bit data and to perform arithmetic and logical operations.
The result of an operation is stored in the accumulator.
Temporary registers:-
The temporary registers W and Z are intended for internal use of the processor and it
cannot be used by the programmer.
The stack pointer (SP) holds the address of the stack top. The stack is a sequence of RAM
memory locations defined by the programmer. The stack is used to save the content
of registers during the execution of a program.
The function of the program counter is to point to the memory address from which the
next byte is to be fetched. When a byte is being fetched, the program counter is
incremented by one to point to the next memory location.
Flags:
The ALU includes five flip-flops that are set or reset according to the result of an operation.
The microprocessor uses the flags for testing the data conditions.
They are Zero (Z), Carry (CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags. The most
commonly used flags are Sign, Zero, and Carry.
C S I I P r a c t i c a l H a n d b o o k P a g e 5 | 34
After execution of any arithmetic and logical operation, if D7 of the result is 1, the sign flag
is set. Otherwise it is reset. If D7 is 1, the number will be viewed as negative number else it is
positive number.
If the result of arithmetic and logical operation is zero, then zero flag is set (1) otherwise it is
reset (0).
If D3 generates any carry when doing any arithmetic and logical operation, this flag is set
(1). Otherwise it is reset (0).
If the result of arithmetic and logical operation contains even number of 1's then this flag
will be set (1) and if it is odd number of 1's it will be reset (0). 8085 uses ODD parity.
If any arithmetic and logical operation generates any carry then carry flag is set (1)
otherwise it is reset (0).
C S I I P r a c t i c a l H a n d b o o k P a g e 6 | 34
If address of source of data as well as address of destination of result is fixed, then
there is no need to give any operand along with the instruction. Ex: - CMA
Microprocessor kit
C S I I P r a c t i c a l H a n d b o o k P a g e 7 | 34
(8)Go to specified memory location to verify the result. Ex: If result is in C032 &
C033 then
Follow following steps:
Reset set C032 INR (See result on display unit) INR C033 data
displayed
C S I I P r a c t i c a l H a n d b o o k P a g e 8 | 34
Board Practical Exam Questions with their solutions
Practical No: 1
Write a program to do addition between two 8 bit numbers. Two numbers are stored
in C030H & C031H. Store the result in C032H.
Program Steps:-
1. This Program is to do addition between two [Link] fetch the data from memory
location [Link] this initialize HL pointer to C030 location.
2. Wherever HL pointer points that memory location’s data can be fetched with use of
memory variable M. Transfer that data from memory variable M to register A.
3. Increment HL pointer, so it points to next memory location C031. Data of C031 can be
taken by memory variable M.
4. By using Arithmetic instruction do the addition between register A (First no) & Memory
variable M (Second no). Result of addition is stored in Accumulator (A).
5. Store the result from Accumulator to Memory location C032.
Flow of the program:-
START
STOP
C S I I P r a c t i c a l H a n d b o o k P a g e 9 | 34
Program:
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B* C* D* E* F H L
0D 00 00 00 7B 00 C0 31
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z X AC X P X CY
0 0 0 0 0 0 0 0
C S I I P r a c t i c a l H a n d b o o k P a g e 10 | 34
Questions: Explain LXI & STA instructions. Which flags are affected with instruction ADD.?
Practical No: 2
Write a program to do addition between two 8 bit BCD numbers. Two numbers are
stored in D030H & D031H. Store the result in D032H onwards starting with least
significant bit.
Program Steps:-
1. This Program is to do addition between two BCD (Binary coded decimal) numbers. First
fetch the data from memory location [Link] this initialize HL pointer to D030 location.
2. Assign a zero to a variable to store carry if generated, register C is used for this. Wherever
HL pointer points that memory location’s data can be fetched with use of memory variable
M. Transfer that data from memory variable M to register A.
3. Increment HL pointer, so it points to next memory location D031. Data of D031 can be
taken by memory variable M.
4. By using Arithmetic instruction do the addition between register A (First no) & Memory
variable M (Second no). Result of addition is stored in Accumulator (A).
5. Result in accumulator is in Hexadecimal. We want result in BCD, so do the conversion with
DAA (Decimal Adjust Accumulator) instruction.
6. After conversion if carry is generated register C value is incremented by [Link] it will
remain 0.
7. Store the result from Accumulator to Memory location D032.
8. Transfer data from register C to Accumulator & store the carry result in D033.
Program:
HexCod
Label Mnemonics Comment
Address e
Operan
Opcode
d
;Initialize HL as a Memory
C000 START LXI H ,D030 21
Pointer
C001 30 ;Lower address byte
C002 D0 Upper address byte.
C003 MVI C,00 H 0E Initialize C reg. with zero.
C004 00
Move the first number in A
C005 MOV A,M 7E
reg.
Increment HL Pointer by
C006 INX H 23
one.
Add accumulator data with
C007 ADD M 86
HL Pointer data
Decimal adjust
C008 DAA 27
accumulator
If carry not generated Jump
C009 JNC C00D D2
to C00D
C00A 0D Lower address byte
C S I I P r a c t i c a l H a n d b o o k P a g e 11 | 34
C00B C0 Upper address byte.
C00C INR C 0C Increment C reg. by one
Store result in memory
C00D L1 STA D032 H 32
location
C00E 32 Lower address byte
C00F D0 Upper address byte.
Move C reg. data to
C010 MOV A,C 79
accumulator
Store carry in memory
C011 STA D033 H 32
location
C012 33 Lower address byte
C013 D0 Upper address byte.
C014 RST 1 CF Stop Program Execution
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B* C D* E* F H L
00 01 00 00 00 10 D0 31
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
0 0 1 0 0
Questions:
C S I I P r a c t i c a l H a n d b o o k P a g e 12 | 34
Practical No: 3
Write a program that subtracts the number stored in C030 H from the number stored
in C031 H. Store the absolute difference in memory location C032H as result.
Program:
Addres HexCod
Label Mnemonics Comment
s e
Operan
Opcode
d
Initialize HL as a memory
C000 LXI H ,C030 21
Pointer.
C001 30 Lower address byte
C002 C0 Upper address byte.
C003 MOV B,M 46 Move subtractor to B reg.
C004 INX H 23 Increment HL Pointer by 1
C005 MOV A,M 7E Move Minuend to A reg.
C006 SUB B 90 Subtract A minus B
If result is positive go to
C007 JP C00D H F2
Label VP
C008 0D Lower address byte
C009 C0 Upper address byte.
Take 1’s complement of A
C00A CMA 2F
reg
Add 1 to A reg to get 2’s
C00B ADI 01 H C6
complement
C00C 01
C00D VP INX H 23 Increment HL Pointer by 1
C00E MOV M,A 77 Move A contents to memory
C00F RST1 CF Stop Program Execution
Note: - As we want absolute result, we use CMA (complement) instruction to get 1’s
complement & then we add 1 to it so we will get 2’s complement.2’s complement of a negative
number gives you Positive number.
Before Execution After Execution
Memory Data Memory Data
Location Location
C030 06 C030 06
C031 0A C031 0A
C S I I P r a c t i c a l H a n d b o o k P a g e 13 | 34
C032 04
GENERAL REGISTERS (* indicates register not used in program .Data after execution for these
register can be changed)
A B C* D* E* F H L
01 06 00 00 00 00 C0 32
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z X AC X P X CY
0 0 0 0 0 0 0 0
Practical No: 04
A block of data is stored in memory locations from C060 H to C06A [Link] block of
data having the same length is stored in memory locations starting from C100. Write
a program to exchange the contents of these two blocks.
Program:
Addres HexCod
Label Mnemonics Comment
s e
Opcode Operand
Move length of Block to c
C000 START MVI C,OB H 0E
reg. as counter.
C001 0B
Store starting Address of
C002 LXI H,C060 21
given data in HL
C003 60 Lower address byte
C004 C0 Upper address byte.
Store starting Address of
C005 LXI D,C100H 11 block in DE where data is to
be transferred.
C006 00 Lower address byte
C007 C1 Upper address byte.
Load Accumulator data in
C008 LOOP LDAX D 1A
memory pointed by DE pair
Copy data pointed by HL
C009 MOV B, M 46
pair to B reg.
Copy Accumulator data to
C00A MOV M, A 77
memory pointed by HL
Copy B reg. data to
C00B MOV A, B 78
Accumulator
Store Accumulator to
C00C STAX D 12
memory pointed by DE
C00D INX H 23 Increment HL by1.
C00E INX D 13 IncrementDE by 1
C00F DCR C 0D Decrement counter by 1
Jump to M.L C008, if C
C010 JNZ C008H C2
(counter) is not zero.
C S I I P r a c t i c a l H a n d b o o k P a g e 14 | 34
C011 08 Lower address byte
C012 C0 Upper address byte.
Stop the program
C013 STOP RST 1 CF
execution.
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B C D E F H L
11 11 00 C1 0B 54 C0 6B
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z X AC X P X CY
0 1 0 1 0 1 0 0
C S I I P r a c t i c a l H a n d b o o k P a g e 15 | 34
Questions:
Practical No: 05
A block of data is stored in memory locations from C080 H to C08B [Link] a program
to transfer the data in reverse order to memory location starting from C180 H.
Program:
Addres HexCod
Label Mnemonics Comment
s e
Opcode Operand
C000 START MVI C,OC H OE Store block length in c reg.
C001 OC
Initialize HL to last address
C002 LXI H,CO8B 21
of source data at C08B H
C003 8B Lower address byte
C004 C0 Upper address byte.
Initialize DE to starting
C005 LXI D,C180 H 11 address of destination
block C180 H
C006 80 Lower address byte
C007 C1 Upper address byte.
Move memory data to
C008 LOOP MOV A,M 7E
accumulator
Store accumulator data to
C009 STAX D 12
memory pointed by DE
C00A DCX H 2B Decrement HL by 1.
C00B INX D 13 IncrementDE by 1.
C00C DCR C 0D Decrement counter C by 1
Jump to C008 if C data is
C00D JNZ C008 C2
not zero
C00E O8 Lower address byte
C00F C0 Upper address byte.
C010 RST1 CF Stop Program.
Details after program execution:
C S I I P r a c t i c a l H a n d b o o k P a g e 16 | 34
Before Execution After Execution
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B* C D E F H L
00 01 00 C1 8C 54 C0 7F
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
0 1 1 1 0
C S I I P r a c t i c a l H a n d b o o k P a g e 17 | 34
Practical No: 06
Write a program to find first occurrence of AB H data. The length of the block is
stored at C07F [Link] data stored from memory location [Link] the address of
this occurrence in HL pair. If data is not found store FFFF H in HL pair.
Program:
Addres HexCod
Label Mnemonics Comment
s e
Operan
Opcode
d
C000 LXI H,C07FH 21 HL pointer points to C07F
C001 7F Lower address byte
C002 C0 Upper address byte.
C003 MOV C, M 4E Move memory data to C reg
Move searched data ABH to A
C004 MVI A,AB H 3E
reg.
C005 AB
C006 S1 : INX H 23 Increment HL by 1
Compare accumulator data &
C007 CMP M BE
memory
If zero flag is set jump to label
C008 JZ C012 H CA
stop
C009 12 Lower address byte
C00A C0 Upper address byte.
C00B DCR C 0D Decrement counter by 1
If C reg not zero then goto
C00C JNZ C006 C2
label S1.
C00D 06 Lower address byte
C00E C0 Upper address byte.
HL pair contents FFFF as data
C00F LXI H,FFFF 21
not available
C010 FF
C011 FF
C012 Stop: RST1 CF Stop the program
Details after program execution:
Before Execution After Execution
Memory Location Data Memory Location Data
C07F 05 C07F 05
C080 21 C080 21
C081 AB C081 AB
C082 33 C082 33
C083 AB C083 AB
C084 BC C084 BC
C S I I P r a c t i c a l H a n d b o o k P a g e 18 | 34
RESULT IS STORED IN “HL” REGISTER PAIR.
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B* C D* E* F H L
AB 01 04 00 00 54 C0 81
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
0 1 1 1 0
C S I I P r a c t i c a l H a n d b o o k P a g e 19 | 34
Practical No: 07
Write a program to find how many times data AD H appears in memory block starting
from C030 H and length of block is at C02F H. Store the count in D000H .
Program:
Addres HexCod
Label Mnemonics Comment
s e
Operan
Opcode
d
C000 MVI C,00 0E Move 00 to C reg
C001 00 H
C002 MVI A,AD H 3E Move AD data to A reg
C003 AD H
H,C02F
C004 LXI 21 Initialize HL with C030
H
C005 2F Lower address byte
C006 C0 Upper address byte.
C007 MOV B,M 46 Move memory data to B reg
C008 INX H 23
Compare accumulator &
C009 BACK CMP M BE
memory data.
If zero flag is not set, goto
C00A JNZ C00E C2
label NEXT
C00B 0E Lower address byte
C00C C0 Upper address byte.
C00D INR C 0C Increment counter by 1
C00E NEXT INX H 23 Increment HL pair by 1
C00F DCR B 05 Decrement B reg
If zero flag not set, goto label
C010 JNZ C009 C2
BACK
C011 09 Lower address byte
C012 C0 Upper address byte.
C013 MOV A,C 79 Move memory data to A reg
Store accumulator data to
C014 STA D000 H 32
memory location 2000
C015 00 Lower address byte
C016 D0 Upper address byte.
C017 RST1 CF Stop the program
C S I I P r a c t i c a l H a n d b o o k P a g e 20 | 34
C031 AD C031 AD
C032 34 C032 34
C033 AD C033 AD
D000 02
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B C D* E* F H L
02 00 02 00 00 54 C0 34
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
0 1 1 1 0
C S I I P r a c t i c a l H a n d b o o k P a g e 21 | 34
Practical No: 08
Program:
Addres HexCod
Label Mnemonics Comment
s e
Operan
Opcode
d
C000 MVI C,08 H 0E Set counter to 08 H
C001 08 H
Set B to 00 to store number of
C002 MVI B,00 H 06
zeros
C003 00 H
C004 LDA C400 H 3A Get number in A
C005 00 Lower address byte
C006 C4 Upper address byte.
Shift Least significant bit in
C007 BACK RRC 0F
carry
C008 JC DA Is carry? Yes go to Next
C009 0C Lower address byte
C00A C0 Upper address byte.
C00B INR B 04 Increment B reg. by 1.
C00C NEXT DCR C 0D Decrement C by 1
C00D JNZ C2 Is counter =0? No go to Back
C00E 07 Lower address byte
C00F C0 Upper address byte.
Get contents of B reg. in A
C010 MOV A,B 78
reg.
C011 STA C500 H 32 Store result in C500 H
C012 00 Lower address byte
C013 C5 Upper address byte.
C014 RST1 CF Stop the program.
Details after program execution:
Before Execution After Execution
Memory Location Data Memory Location Data
C400 75 C400 75
C500 03
GENERAL REGISTERS
C S I I P r a c t i c a l H a n d b o o k P a g e 22 | 34
(* indicates register not used in program .Data after execution for these register can be
changed)
A B C D* E* F H* L*
03 03 00 00 00 54 FF FE
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
0 1 1 1 0
Practical No: 09
Write a program that multiplies two 1-byte hex numbers stored in consecutive
memory locations starting from C030 Store the two-byte result in consecutive
memory locations starting from C032 beginning with lower order byte.
Program:
Addres HexCod
Label Mnemonics Comment
s e
Opcod Operan
e d
C000 START XRA A AF Clear the A reg. to zero
Initialize B reg. to zero to record
C001 MOV B, A 47
higher byte
Initialize HL reg. as memory
C002 LXI H ,C030 21
pointer
C003 30 Lower address byte
C004 C0 Upper address byte.
C005 MOV C, M 4E Move length in C reg.
C006 INX H 23 Increment HL Pointer by one.
Add memory content to
C007 L1 ADD M 86
Accumulator
C008 JNC C00C H D2 If cy=0 then jump to label P1
C009 OC Lower address byte
C00A C0 Upper address byte.
C00B INR B 04 Increment B reg. by one.
C00C P1 DCR C OD Decrement C reg. by one.
If counter c is not zero goto
C00D JNZ C007 C2
label L1
C00E 07 Lower address byte
C00F C0 Upper address byte.
C010 INX H 23 Increment HL Pointer by one
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B C D* E* F H L
2D 00 00 00 00 54 C0 33
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
0 1 1 1 0
Questions:
1. Explain XRA instruction & write another instruction for same operation as XRA in above
program.
C S I I P r a c t i c a l H a n d b o o k P a g e 24 | 34
Practical No: 10
Write a program that divides two 1-byte hex numbers where the dividend is stored in
C030 H and the divisor stored in C031 H. Store the quotient and the reminder in the
next consecutive memory locations respectively.
Program:
Addres HexCod
Label Mnemonics Comment
s e
Operan
Opcode
d
C000 START XRA A AF Clear the A reg. to zero.
Initialize B reg. to zero to
C001 MOV B,A 47
record quotient.
Initialize HL as a memory
C002 LXI H ,C030 21
Pointer.
C003 30 Lower address byte
C004 C0 Upper address byte.
C005 MOV A, M 7E Move dividend in A reg.
Increment HL Contents by
C006 INX H 23
one.
Compare to check dividend is
C007 PP CMP M BE
greater than divisor
C008 JC C010 H DA If A<M then go to label VP
C009 10 Lower address byte
C00A C0 Upper address byte.
C00B SUB M 96 Subtract divisor from dividend
C00C INR B 04 Increment quotient by one.
Jump unconditionally to Label
C00D JMP C007 C3
PP
C00E 07 Lower address byte
C00F C0 Upper address byte.
Increment HL Contents by
C010 VP INX H 23
one.
C011 Store quotient at C032 H
MOV M,B 70
Increment HL Contents by
C012 INX H 23
one.
C013 MOV M,A 77 Store reminder at C033 H
C014 RST1 CF Stop the Execution.
C S I I P r a c t i c a l H a n d b o o k P a g e 25 | 34
C030 0D C030 0D
C031 03 C031 03
C032 04
C033 01
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B C* D* E* F H L
01 04 00 00 00 81 C0 33
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
1 0 0 0 1
Questions:
C S I I P r a c t i c a l H a n d b o o k P a g e 26 | 34
Practical No: 11
Write a program that adds the BCD contents of a block of memory. Block length in hex
not exceeding 63H=9910 is stored at C0FF and starting address of block is C100. Store
the BCD sum as result starting from memory location C060.
Program:
C S I I P r a c t i c a l H a n d b o o k P a g e 27 | 34
Details after program execution:
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B C D* E* F H L
00 00 00 00 00 44 C1 04
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
0 1 0 1 0
C S I I P r a c t i c a l H a n d b o o k P a g e 28 | 34
Practical No : 12
Write a program that adds the contents of a block of memory using DAD instruction.
Block length stored at D100 and starting address of block is D101. Store the two byte
result below the end of the block.
Program Steps:-
1. This Program is to do addition between values stored in memory locations with use of DAD
instruction (16 bit addition).
2. First fetch the data from memory location [Link] this initialize HL pointer to D100
location.D100 in having length of the block store it in register A (i.e how many numbers to
be added).
3. Initialize 00 to register pair BC & DE.
4. Increment HL & transfer first number to register C. consider first number is “05”, so BC
value will become “0005”. DE value is “0000” & HL value is “D101”.
5. With XCHG instruction exchange the data of DE & HL, as we are using DAD instruction in
which one number should be there in HL pair. So after exchange HL will have “0000” & DE
will have “D101”.
6. Add the value of BC & HL. Result will be stored in HL register.
BC=0005 (first number) HL= 0000 (Initial value) DE= D101.
Addition result will be HL=HL+BC so HL= 0005.
7. Again exchange the contents of HL & DE. HL will point to next memory.
8. Decrement counter value A. If it is not zero repeat step no 5 to 7 till value of a become
zero.
9. Store the result of addition from register DE to the end of the block.
Program:
Addres
Label Mnemonics HexCode Comment
s
Operan
Opcode
d
C000 START LXI H,D100 21 Initialize HL as a Memory Pointer
C001 00 Lower address byte
C002 D1 Upper address byte.
C003 MOV A, M 7E Move the length of block in A reg.
C004 LXI B,0000 01 Initialize BC reg. to 0000 H
C005 00
C006 00
C007 LXI D ,0000 11 Initialize DE reg. to 0000 H
C008 00
C009 00
C00A V1 INX H 23 Increment HL Pointer by one.
C00B MOV C, M 4E
C S I I P r a c t i c a l H a n d b o o k P a g e 29 | 34
C00C XCHG EB Exchange HL contents with DE
C00D DAD B 09 Add BC contents with HL.
C00E XCHG EB Exchange HL contents with DE
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B C D E F H L
00 00 02 00 12 54 D1 07
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
0 1 1 1 0
Questions:
C S I I P r a c t i c a l H a n d b o o k P a g e 30 | 34
1. Explain working of DAD instructions with example.
2. Why XCHG instruction is used in this program.
3. Explain Flag register.
Practical No: 13
Write a program that uses keyboard subroutine having starting address 02E7 to
accept two digits from the keypad. Store them separately in consecutive memory
locations C030 to C031 and store them as one byte data at memory location C032.
Program:
C S I I P r a c t i c a l H a n d b o o k P a g e 31 | 34
C3017 STOP RST 1 CF Stop program execution
Note:- We are using inbuilt keyboard subroutine in above program to accept data from user
during program execution. Keyboard subroutine is stored at 02E7 memory location (For Dynakit).
GENERAL REGISTERS
(* indicates register not used in program .Data after execution for these register can be
changed)
A B C D E F H* L*
23 C0 32 03 85 00 FF FE
FLAG REGISTER
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
0 0 0 0 0
C S I I P r a c t i c a l H a n d b o o k P a g e 32 | 34
Practical No: 14
Write a program for using the microprocessor kit as a calculator that would accept
number & display the sum. Use monitor routines to input the numbers & output the
numbers to the display.
Program:
Addres HexCod
Label Mnemonics Comment
s e
Opcod Operan
e d
C000 START LXI SP,C700 31 Initialize stack pointer at stack
C001 00 Lower address byte
C002 C7 Upper address byte.
Call keyboard monitor routine
C003 CALL O2E7 CD
called RDKBD
C004 E7 Lower address byte
C005 02 Upper address byte.
C006 MOV D,A 57 Store A contents to D
Call keyboard monitor routine
C007 CALL O2E7 CD
called RDKBD
C008 E7 Lower address byte
C009 02 Upper address byte.
C00A ADD D 82 Add D contents with A.
Decimally adjust the
C00B DAA 27
accumulator
Call monitor routine called
C00C CALL 036E H CD
which display’s A [Link]
C00D 6E Lower address byte
C00E O3 Upper address byte.
C00F JMP C003 C3 Jump unconditionally
C010 O3 Lower address byte
C011 C0 Upper address byte.
Note:- We are using inbuilt keyboard subroutine in above program to accept data from user
during program execution. Keyboard subroutine is stored at 02E7 memory location (For Dynakit).
We are also using display subroutine to display output on 7 segment display. Display subroutine
is stored at 036E memory location.
C S I I P r a c t i c a l H a n d b o o k P a g e 34 | 34