Microprocessor Lab Manual
Microprocessor Lab Manual
Date of Date of
S No Name of the Experiment Page No Marks Staff Signature
Experiment Submission
2 8-BIT ADDITION
3 8-BIT SUBTRACTION
4 8-BIT MULTIPLICATION
5 8-BIT DIVISION
6 16-BIT ADDITION
7 16-BIT SUBTRACTION
10 16-BIT MULTIPLICATION
16 TABLE PROCESSING
20 FACTORIAL OF A NUMBER
1.8085 architecture
Control Unit
Generates signals within uP to carry out the instruction, which has been decoded. In
reality causes certain connections between blocks of the uP to be opened or closed, so
that data goes where it is required, and so that ALU operations occur.
Registers
The 8085/8080A-programming model includes six registers, one accumulator, and
one flag register, as shown in Figure. In addition, it has two 16-bit registers: the stack
pointer and the program counter. They are described briefly as follows.
The 8085/8080A has six general-purpose registers to store 8-bit data; these are
identified as B,C,D,E,H, and L as shown in the figure. They can be combined as
register pairs - BC, DE, and HL - to perform some 16-bit operations. The
programmer can use these registers to store or copy data into the registers by using
data copy instructions.
Accumulator
The accumulator is an 8-bit register that is a part of 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. The accumulator is also
identified as register A.
Flags
The ALU includes five flip-flops, which are set or reset after an operation according
to data conditions of the result in the accumulator and other registers. They are called
Zero(Z), Carry (CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags; they are
listed in the Table and their bit positions in the flag register are shown in the Figure
below. The most commonly used flags are Zero, Carry, and Sign. The microprocessor
uses these flags to test data conditions.
For example, after an addition of two numbers, if the sum in the accumulator id larger
than eight bits, the flip-flop uses to indicate a carry -- called the Carry flag (CY) -- is
set to one. When an arithmetic operation results in zero, the flip-flop called the
Zero(Z) flag is set to one. The first Figure shows an 8-bit register, called the flag
register, adjacent to the accumulator. However, it is not used as a register; five bit
positions out of eight are used to store the outputs of the five flip-flops. The flags are
stored in the 8-bit register so that the programmer can examine these flags (data
conditions) by accessing the register through an instruction.
These flags have critical importance in the decision-making process of the micro-
processor. The conditions (set or reset) of the flags are tested through the software
instructions. For example, the instruction JC (Jump on Carry) is implemented to
change the sequence of a program when CY flag is set. The thorough understanding
of flag is essential in writing assembly language programs.
This 16-bit register deals with sequencing the execution of instructions. This register
is a memory pointer. Memory locations have 16-bit addresses, and that is why this is a
16-bit register.
The microprocessor uses this register to sequence the execution of the instructions.
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 (machine code) is being fetched, the program
counter is incremented by one to point to the next memory location
The stack pointer is also a 16-bit register used as a memory pointer. It points to a
memory location in R/W memory, called the stack. The beginning of the stack is
defined by loading 16-bit address in the stack pointer. The stack concept is explained
in the chapter "Stack and Subroutines."
Instruction Register/Decoder
Temporary store for the current instruction of a program. Latest instruction sent here
from memory prior to execution. Decoder then takes instruction and ‘decodes’ or
interprets the instruction. Decoded instruction then passed to next stage.
Memory Address Register
Holds address, received from PC, of next program instruction. Feeds the address bus
with addresses of location of the program under execution.
Control Generator
Generates signals within uP to carry out the instruction which has been decoded. In
reality causes certain connections between blocks of the uP to be opened or closed, so
that data goes where it is required, and so that ALU operations occur.
Register Selector
This block controls the use of the register stack in the example. Just a logic circuit
which switches between different registers in the set will receive instructions from
Control Unit.
uP requires extra registers for versatility. Can be used to store additional data during a
program. More complex processors may have a variety of differently named registers.
ALE (Output)
Address Latch Enable: It occurs during the first clock cycle of a machine state and
enables the address to get latched into the on chip latch of peripherals. The falling
edge of ALE is set to guarantee setup and hold times for the address information.
ALE can also be used to strobe the status information. ALE is never 3stated.
SO, S1 (Output)
Data Bus Status. Encoded status of the bus cycle:
S1 S0
O O HALT
0 1 WRITE
1 0 READ
1 1 FETCH
S1 can be used as an advanced R/W status.
RD (Output 3state)
READ; indicates the selected memory or 1/0 device is to be read and that the Data
Bus is available for the data transfer.
WR (Output 3state)
WRITE; indicates the data on the Data Bus is to be written into the selected memory
or 1/0 location. Data is set up at the trailing edge of WR. 3stated during Hold and Halt
modes.
READY (Input)
If Ready is high during a read or write cycle, it indicates that the memory or
peripheral is ready to send or receive data. If Ready is low, the CPU will wait for
Ready to go high before completing the read or write cycle.
HOLD (Input)
HOLD; indicates that another Master is requesting the use of the Address and Data
Buses. The CPU, upon receiving the Hold request. will relinquish the use of buses as
soon as the completion of the current machine cycle. Internal processing can continue.
The processor can regain the buses only after the Hold is removed. When the Hold is
acknowledged, the Address, Data, RD, WR, and IO/M lines are 3stated.
HLDA (Output)
HOLD ACKNOWLEDGE; indicates that the CPU has received the Hold request and
that it will relinquish the buses in the next clock cycle. HLDA goes low after the Hold
request is removed. The CPU takes the buses one half clock cycle after HLDA goes
low.
INTR (Input)
INTERRUPT REQUEST; is used as a general purpose interrupt. It is sampled only
during the next to the last clock cycle of the instruction. If it is active, the Program
Counter (PC) will be inhibited from incrementing and an INTA will be issued. During
this cycle a RESTART or CALL instruction can be inserted to jump to the interrupt
service routine. The INTR is enabled and disabled by software. It is disabled by Reset
and immediately after an interrupt is accepted.
INTA (Output)
INTERRUPT ACKNOWLEDGE; is used instead of (and has the same timing as) RD
during the Instruction cycle after an INTR is accepted. It can be used to activate the
8259 Interrupt chip or some other interrupt port.
RST 5.5
RST 6.5 - (Inputs)
RST 7.5
RESTART INTERRUPTS; These three inputs have the same timing as I NTR except
they cause an internal RESTART to be automatically inserted.
RST 7.5 ~~ Highest Priority
RST 6.5
RST 5.5 o Lowest Priority
The priority of these interrupts is ordered as shown above. These interrupts have a
higher priority than the INTR.
TRAP (Input)
Trap interrupt is a nonmaskable restart interrupt. It is recognized at the same time as
INTR. It is unaffected by any mask or Interrupt Enable. It has the highest priority of
any interrupt.
RESET IN (Input)
Reset sets the Program Counter to zero and resets the Interrupt Enable and HLDA
flipflops. None of the other flags or registers (except the instruction register) are
affected The CPU is held in the reset condition as long as Reset is applied.
X1, X2 (Input)
Crystal or R/C network connections to set the internal clock generator X1 can also be
an external clock input instead of a crystal. The input frequency is divided by 2 to
give the internal operating frequency.
CLK (Output)
Clock Output for use as a system clock when a crystal or R/ C network is used as an
input to the CPU. The period of CLK is twice the X1, X2 input period.
IO/M (Output)
IO/M indicates whether the Read/Write is to memory or l/O Tristated during Hold and
Halt modes.
SID (Input)
Serial input data line The data on this line is loaded into accumulator bit 7 whenever a
RIM instruction is executed.
SOD (output)
Serial output data line. The output SOD is set or reset as specified by the SIM
instruction.
Vcc
+5 volt supply.
Vss
Ground Reference.
Program Format:
Aim:
Algorithm:
Input Output
9100 – 04 9200 – 0C
9101 – 08 9201 – 00
9100 – FF 9200 – FE
9101 – FF 9201 – 01
Program:
MVI C, 00
LDA 9100
MOV B, A
LDA 9101
ADD B
JNC L1:
INR C
L1 : STA 9200
MOV A, C
STA 9201
RST 1
Result:
The ALP to perform 8-bit addition was executed and its output verified.
Program Format:
Aim:
Algorithm:
Input Output
9200 – FF 9200 – 55
9201 – AA 9201 – 01
9200 – BB 9200 – 44
9201 – FF 9201 – 00
Program:
MVI C, 00
LDA 9200
MOV B, A
LDA 9201
SUB B
JNC L1
CMA
INR A
INR C
L1 : STA 9200
MOV A, C
STA 9201
RST 1
Result:
The ALP to perform 8-bit subtraction was executed and its output verified.
Program Format:
Aim:
Algorithm:
Input Output
9100 – 05 9102 – 14
9101 – 04 9103 – 00
9100 – FF 9102 – FE
9101 – FF 9103 – 01
Program:
MVI C, 00
LDA 9100
MOV B, A
LDA 9101
MOV D, A
MVI A, 00
L2 : ADD D
JNC L1:
INR C
L1 : DCR B
JNZ L2:
STA 9102
MOV A, C
STA 9103
RST 1
Result:
The ALP to perform 8-bit multiplication was executed and its output verified.
Program Format:
; Compare A
9009 B8 L1 : CMP B
and B
; If carry, go to
900A DA 12 90 JC 9012(L2) L2
Aim:
Algorithm:
Input Output
MVI C, 00
LDA 9100
MOV B, A
LDA 9101
L1 : CMP B
JC L2:
SUB B
INR C
JMP L1:
STA 9103
MOV A, C
L2 : STA 9102
RST 1
Result:
The ALP to perform 8-bit division was executed and its output verified.
Program Format:
; L ← [9100]
9002 2A 00 91 LHLD 9100
H ← [9101]
;E ← L
9005 EB XCHG
D←H
; L ← [9102]
9006 2A 02 91 LHLD 9102
H ← [9103]
;L ← L+E
9009 19 DAD D
H ←H+D
; If no carry, go
900A D2 0E 90 JNC 900E(L1)
to L1
900D 0C INR C ;C ← C+1
; [9104] ← L
900E 22 04 91 L1: SHLD 9104
[9105] ← H
9011 79 MOV A, C ;A ← C
9012 32 06 91 STA 9106 ; [9106] ← A
9015 CF RST 1 ; Reset
Expt. No: 6 Page No:
Aim:
Algorithm:
Input Output
9100 – 06 9104 – 09
9101 – 05 9105 – 0B
9102 – 03 9106 – 00
9103 – 06
9100 – 06 9104 – 09
9101 – F0 9105 – E0
9102 – 03 9106 – 01
9103 – F0
Program:
MVI C, 00
LHLD 9100
XCHG
LHLD 9102
DAD D
JNC L1
INR C
L1 : SHLD 9104
MOV A, C
STA 9106
RST 1
Result:
The ALP for adding two 16-bit numbers was executed and its output verified.
Program Format:
;E ← L
9003 EB XCHG
D←H
; L ← [9102]
9004 2A 02 91 LHLD 9102
H ← [9103]
9007 7D MOV A, L ;A ← L
9008 93 SUB E ;A ← A–E
9009 6F MOV L, A ;L ← A
900A 7C MOV A, H ;A ← H
;A ← A–D–
900B 9A SBB D
CARRY
900C 67 MOV H, A ;H ← A
; [9200] ← L
900D 22 00 92 SHLD 9200
[9201] ← H
9010 CF RST 1 ; Reset
Expt. No: 7 Page No:
Aim:
Algorithm:
Input Output
9100 – 06 9200 – 03
9101 – 05 9201 – 01
9102 – 09
9103 – 06
9100 – 06 9200 – 02
9101 – 08 9201 – FE
9102 – 08
9103 – 06
Program:
LHLD 9100
XCHG
LHLD 9102
MOV A, L
SUB E
MOV L, A
MOV B, H
SBB D
MOV H, A
SHLD 9200
RST 1
Result:
The ALP for subtracting two 16-bit numbers was executed and its output verified.
Program Format:
; H ←92
9006 21 00 92 LXI H, 9200
; L ← 00
; D ← 93
9009 11 00 93 LXI D, 9300
; E ← 00
; If not zero
9012 C2 OC 90 JNZ 900C(L1)
jump to L1
Aim:
Algorithm:
Input Output
9100 – 04
9200 – 05 9200 – 08
9201 – 03 9201 – 05
9202 – 08 9202 – 0B
9203 – 01 9203 – 09
9300 – 03
9301 – 02
9302 – 03
9303 – 08
Program:
STC
CMC
LDA 9100
MOV C, A
LXI H, 9200
LXI D, 9300
L1: LDAX D
ADC M
MOV M, A
INX D
INX H
DCR C
JNZ L1
RST 1
Result:
The ALP for adding two multi byte data was executed and its output verified.
Program Format:
; H ← 92
9006 21 00 92 LXI H, 9200
; L ← 00
; D ←93
9009 11 00 93 LXI D, 9300
; E ← 00
Aim:
Algorithm:
Input Output
9100 – 02
9200 – 08 9200 – FB
9201 – 04 9201 – FD
9202 – 02 9202 – 00
9203 – 01 9203 – 07
9300 – 03
9301 – 02
9302 – 03
9303 – 08
Program:
STC
CMC
LDA 9100
MOV C , A
LXI H, 9200
LXI D, 9300
L1 : LDAX D
SBB M
MOV M, A
INX D
INX H
DCR C
JNZ L1
RST 1
Result:
The ALP for subtracting two multi byte data was executed and its output verified.
Program Format:
9009 ; D ← FF
11 FF FF LXI D, FFFF
E ← FF
900C 39 L2 : DAD SP ; HL ← HL + SP
; If no carry,
900D D2 11 90 JNC L1
jump to L1
9010 03 INX B ; BC ← BC + 1
9011 1B L1 : DCX D ; DE ← DE - 1
9012 7A MOV A, D ;A ←D
9013 B2 ORA E ; A ← A OR E
; If no zero,
9014 C2 0C 90 JNZ 900c(L2)
jump to L2
; [9200] ← L
9017 22 00 92 SHLD 9200
[9201] ← H
901A 69 MOV L, C ;L ←C
901B 60 MOV H, B ;H ←B
; [9202] ← L
901C 22 02 92 SHLD 9202
[9203] ← H
901F CF RST 1 ; Reset
Expt. No: 10 Page No:
Aim:
Algorithm:
Input Output
FFFF 9200 – 01
FFFF 9201 – 00
9202 – FE
9203 – FF
Program:
LXI H, 0000
LXI B, 0000
LXI SP, FFFF
LXI D, FFFF
L2 : DAD SP
JNC L1
INX B
L1 : DCX D
MOV A, D
ORA E
JNZ L2
SHLD 9200
MOV L, C
MOV H, B
SHLD 9202
RST 1
Result:
The ALP to perform 16-bit multiplication was executed and its output verified.
Program Format:
; Compare A
9007 BE CMP M
and M
; If no carry,
9008 D2 0C 90 JNC L1
jump to L1
Aim:
Algorithm:
1. Initialize one register pair (HL) with the starting address of the array
2. Initialize one register (Reg B) with one count less than the length of the array
3. Move the memory content to accumulator
4. Increment HL pair
5. Compare the contents of accumulator and memory
6. Check for carry, if no carry, go to step 8
7. Move the memory content to accumulator
8. Decrement Reg B
9. Check for zero, if not zero, go to step 4
10. Store the accumulator content in a memory location
11. Stop
Sample Data:
Input Output
9100 – 08
9101 – 0A
9102 – 02
9103 – 0C 9200 – 19
9104 – 08
9105 – 06
9106 – 00
9107 – 19
Program:
LXI H, 9100
MVI B, 07
MOV A, M
L2 : INX H
CMP M
JNC L1
MOV A, M
L1 : DCR B
JNZ L2
STA 9200
RST 1
Result:
The ALP to search the largest value in an array was executed and its output verified.
Program Format:
; Compare A
9007 BE CMP M
and M
; If carry, jump
9008 DA 0C 90 JC 900C(L1)
to L1
Aim:
Algorithm:
1. Initialize one register pair (HL) with the starting address of the array
2. Initialize one register (Reg B) with one count less than the length of the array
3. Move the memory content to accumulator
4. Increment HL pair
5. Compare the contents of accumulator and memory
6. Check for carry, if there is carry, go to step 8
7. Move the memory content to accumulator
8. Decrement Reg B
9. Check for zero, if not zero, go to step 4
10. Store the accumulator content in a memory location
11. Stop
Sample Data:
Input Output
9100 – 08
9101 – 0A
9102 – 02
9103 – 0C 9200 – 00
9104 – 08
9105 – 06
9106 – 00
9107 – 19
Program:
LXI H, 9100
MVI B, 07
MOV A, M
L2 : INX H
CMP M
JC L1
MOV A, M
L1 : DCR B
JNZ L2
STA 9200
RST 1
Result:
The ALP to search the smallest value in an array was executed and its output
verified.
Program Format:
9009 23 INX H ; HL ← HL + 1
; Compare A
900A BE CMP M
and M
; If carry, jump
900B DA 13 90 JC 9013(L1) to L1
900E 56 MOV D, M ;D ←M
900F 77 MOV M, A ;M ←A
9010 2B DCX H ; HL ← HL – 1
9011 72 MOV M, D ;M ←D
9012 23 INX H ; HL ← HL + 1
9013 0D L1 : DCR C ;C←C–1
; If no zero,
9014 C2 08 90 JNZ 9008(L2)
jump to L2
9017 05 DCR B ;B←B–1
; If no zero,
9018 C2 02 90 JNZ L3
jump to L3
901B CF RST 1 ; Reset
Expt. No: 13 Page No:
Aim:
Algorithm:
1. Initialize one register (Reg B) with one count less than the length of the array
2. Initialize one register pair (HL) with the starting address of the array
3. Initialize one register (Reg C) with the length of the array
4. Decrement the inner counter - Reg C
5. Move the memory content to accumulator
6. Increment HL pair
7. Compare the contents of accumulator and memory
8. Check for carry, if there is carry, go to step 13
9. Move the memory content to Reg D
10. Move the accumulator content to memory
11. Decrement HL pair
12. Move the content of Reg D to memory
13. Increment HL pair
14. Decrement the inner counter – Reg C
15. Check for zero, if not zero, go to step 5
16. Decrement the outer counter - Reg B
17. Check for zero, if not zero, go to step 2
18. Stop
Sample Data:
Input Output
9100 – 08 9100 – 00
9101 – 0A 9101 – 02
9102 – 02 9102 – 06
9103 – 0C 9103 – 08
9104 – 08 9104 – 08
9105 – 06 9105 – 0A
9106 – 00 9106 – 0C
9107 – 19 9107 – 19
Program:
MVI B, 07
L3 : LXI H, 9100
MVI C, 08
DCR C
L2 : MOV A, M
INX H
CMP M
JC L1
MOV D, M
MOV M, A
DCX H
MOV M, D
L1 : INX H
DCR C
JNZ L2
DCR B
JNZ L3
RST 1
Result:
The ALP to sort an array in ascending order was executed and its output verified.
Program Format:
9009 23 INX H ; HL ← HL + 1
; Compare A
900A BE CMP M
and M
; If no carry,
900B DA 13 90 JNC L1
jump to L1
900E 56 MOV D, M ;D ←M
900F 77 MOV M, A ;M ←A
9010 2B DCX H ; HL ← HL – 1
9011 72 MOV M, D ;M ←D
9012 23 INX H ; HL ← HL + 1
9013 0D L1 : DCR C ;C←C–1
; If no zero,
9014 C2 08 90 JNZ L2
jump to L2
9017 05 DCR B ;B←B–1
; If no zero,
9018 C2 02 90 JNZ L3
jump to L3
901B CF RST 1 ; Reset
Expt. No: 14 Page No: 50
Aim:
Algorithm:
1. Initialize one register (Reg B) with one count less than the length of the array
2. Initialize one register pair (HL) with the starting address of the array
3. Initialize one register (Reg C) with the length of the array
4. Decrement the inner counter - Reg C
5. Move the memory content to accumulator
6. Increment HL pair
7. Compare the contents of accumulator and memory
8. Check for carry, if there is no carry, go to step 13
9. Move the memory content to Reg D
10. Move the accumulator content to memory
11. Decrement HL pair
12. Move the content of Reg D to memory
13. Increment HL pair
14. Decrement the inner counter – Reg C
15. Check for zero, if not zero, go to step 5
16. Decrement the outer counter - Reg B
17. Check for zero, if not zero, go to step 2
18. Stop
Sample Data:
Input Output
9100 – 08 9100 – 19
9101 – 0A 9101 – 0C
9102 – 02 9102 – 0A
9103 – 0C 9103 – 08
9104 – 08 9104 – 08
9105 – 06 9105 – 06
9106 – 00 9106 – 02
9107 – 19 9107 – 00
Program:
MVI B, 07
L3 : LXI H, 9100
MVI C, 08
DCR C
L2 : MOV A, M
INX H
CMP M
JNC L1
MOV D, M
MOV M, A
DCX H
MOV M, D
L1 : INX H
DCR C
JNZ L2
DCR B
JNZ L3
RST 1
Result:
The ALP to sort an array in descending order was executed and its output verified.
Program Format:
; H ← 91
9002 21 00 91 LXI H, 9100
; L ← 00
; D ←92
9005 11 05 92 LXI D, 9205
; E ← 05
9008 7E L1 : MOV A, M ;A ←M
9009 12 STAX D ; DE ← A
900A 23 INX H ; HL ← HL + 1
900B 1B DCX D ; DE ← DE – 1
900C 05 DCR B ;B←B–1
; If no zero
900D C2 08 90 JNZ L1
jump to L1
9010 CF RST 1 ; Reset
Expt. No: 15 Page No:
Aim:
Algorithm:
Input Output
9100 – 0E 9200 – 0C
9101 – 0E 9201 – 00
9102 – 0F 9202 – 0F
9103 – 0F 9203 – 0F
9104 – 00 9204 – 0E
9105 – 0C 9205 – 0E
Program:
MVI B, 06
LXI H, 9100
LXI D, 9205
L1 : MOV A, M
STAX D
INX H
DCX D
DCR B
JNZ L1
RST1
Result:
The ALP for reversing a given string was executed and its output verified.
Program Format:
Aim:
To write an ALP to find the square of a given data from a lookup table.
Algorithm:
1. Initialize one register pair (HL) with the starting address of the source array
2. Load the accumulator with the input data stored in a memory location
3. Move the accumulator content to L
4. Move the memory content to accumulator
5. Store the accumulator content in memory
6. Stop
Sample Data:
9100 – 00
9101 – 01
9104 – 10
9105 – 19
Program:
LXI H, 9100
LDA 9200
MOV L, A
MOV A, M
STA 9201
RST 1
Result:
The ALP for finding the square of a given number from a lookup table was executed
and its output verified.
Program Format:
Aim:
Algorithm:
1. Load the accumulator with the MSB of the given BCD number from a memory
address
2. Initialize one register (Reg B) with immediate data 0A
3. Move the accumulator content to a register (Reg D)
4. Clear the accumulator
5. Add Reg D content to accumulator
6. Decrement Reg D
7. Check for zero, if not zero, go to step 5
8. Move the accumulator content to Reg C
9. Load the accumulator with the LSB of the given BCD number from a memory
address
10. Add Reg C content to accumulator
11. Store the accumulator content in a memory location
12. Stop
Sample Data:
Input Output
9101 – 08 (LSB)
Program:
LDA 9100
MVI B, 0A
MOV D, A
MVI A, 00
L1 : ADD D
DCR B
JNZ L1
MOV C, A
LDA 9101
ADD C
STA 9102
RST 1
Result:
The ALP for converting a given BCD number to HEX number was executed and its
output verified.
Program Format:
Aim:
Algorithm:
1. Clear one register pair (BC) for storing hundreds and tens
2. Load the accumulator with the HEX number from a memory address
3. Subtract 64H (100D) from accumulator
4. Check for carry, if there is carry go to step 7
5. Increment Reg B
6. Go to step 3
7. Add 64H (100D) to accumulator
8. Subtract 0AH (10D) from accumulator
9. Check for carry, if there is carry go to step 12
10. Increment Reg C
11. Go to step 8
12. Add 0AH (10D) to accumulator
13. Store the ones in accumulator in a memory location
14. Move the tens in Reg C to accumulator
15. Store the tens in accumulator in a memory location
16. Move the hundreds in Reg B to accumulator
17. Store the hundreds in accumulator in a memory location
18. Stop
Sample Data:
Input Output
9201 – 05 (10’s)
9202- 02 (100’s)
Program:
LXI B, 0000
LDA 9100
L2 : SUI 64
JC L1
INR B
JMP L2
L1 : ADI 64
L4 : SUI 0A
JC L3
INR C
JMP L4
L3 : ADI 0A
STA 9200
MOV A, C
STA 9201
MOV A, B
STA 9202
RST 1
Result:
The ALP for converting a given HEX number to BCD number was executed and its
output verified.
Program Format:
; Compare A
9009 BE CMP M
and M
; If no zero,
900A C2 0E 90 JNZ L1
jump to L1
Aim:
To write an ALP to search a given data and count its occurrences in an array.
Algorithm:
1. Clear one register (Reg C) for the count of occurrence of the given data
2. Initialize one register pair (HL) with the starting address of the array
3. Initialize one register (Reg B) with the count of elements in the array
4. Move the memory content to accumulator
5. Increment HL pair
6. Compare the contents of accumulator and memory
7. Check for zero, if not zero, go to step 9
8. Increment Reg C
9. Decrement Reg B
10. Check for zero, if not zero, go to step 5
11. Move the content of Reg C to accumulator
12. Store the accumulator content in a memory address
13. Stop
Sample Data:
Input Output
9101 – 02
9102 – 05
9103 – 04 9200 – 02
9104 – 06
9105 – 01
9106 – 04
Program:
MVI C, 00
LXI H, 9100
MVI B, 06
MOV A, M
L2 : INX H
CMP M
JNZ L1
INR C
L1 : DCR B
JNZ L2
MOV A, C
STA 9200
RST 1
Result:
The ALP to search a given data and count its occurrences in an array was executed
and its output verified.
Program Format:
9007 3E 00 MVI A, 00 ; A ← 00
9009 80 L1 : ADD B ;A←A+B
900A 15 DCR D ;D ←D–1
; If no zero,
900B C2 09 90 JNZ L1
jump to L1
900E 47 MOV B, A ;B←A
900F 0D DCR C ;C ←C–1
; If no zero,
9010 C2 06 90 JNZ L2
jump to L2
9013 32 01 91 STA 9101 ; [9101] ← A
9016 CF RST 1 ; Reset
Expt. No: 20 Page No:
Aim:
Algorithm:
Input Output
9100 – 04 9101 – 18
Program:
LDA 9100
MOV B, A
MOV C, A
DCR C
L2 : MOV D, C
MVI A, 00
L1 : ADD B
DCR D
JNZ L1
MOV B, A
DCR C
JNZ L2
STA 9101
RST 1
Result:
The ALP to search a given data and count its occurrences in an array was executed
and its output verified.
KIT ENTERING PROCEDURE
NEXT INSTRUCTION .
. .
RST 1
2. TO ENTER DATA
-M9100(FOR EXAMPLE)
DATA 1
SPACE BAR
DATA 2
SPACE BAR
- G9000(FOR EXAMPLE)
RESULT 1
SPACE BAR
RESULT 2