Micro processor Lab Manual / Count number of 1 s in 8 bit number ALP

Program Name

Write a Assembly Language Program for Count number of 1 s in 8 bit number.
Theory
Instruction Mnemonic Operand Comments
MVI C,08 Move 08 to register C as this act as a loop for rotating 8 times
LDA 8100 Loading the contents of 8100 to accumulator to perform given task
MVI B,00 Move 00 to reg. B, it acts as a counter to perform rotation 8 times
RAL Rotating accumulator from left 8 times till JNZ becomes false
JNC Fwd Jumping to DCR if the carry flag if zero
INR B Incrementing value of reg. B by 1 as it has to execute only 8 times
DCR C Decrementing reg. C
JNZ Bk Jumping back to RAL if condition is not zero to perform rotation
MOV A,B Move the contents of reg. B to accumulator
STA 8200 Store content of accumulator to memory 8200 for displaying result
HLT Stop
Program Code


Online compiler for 8085 Microprocess Compiler


Home     Back