In this program, we will write an 8085 Program to find the square of numbers in the 8085 microprocessor with a program flow chart and explanation of the program.
8085 Program to find the square of numbers
Program Statement
Write a program in the assembly language of 8085 to find the square of numbers from memory location D100H and store the result from location D200H.
Explanation of Program
- To find the square of a number we need to multiply the number with itself.
- Store the result.
Flow Chart of Program
Assembly Language Program
Label | Instruction | Comment |
---|---|---|
LXI D, D100H | Initialize lookup table pointer | |
LXI D, D000H | Initialize source memory pointer | |
LXI B, D200H | Initialize destination memory pointer | |
BACK: | LDAX D | Get the number |
MOV L, A | A point to the square | |
MOV A, M | Get the square | |
STAX B | store the result at the destination memory location | |
INX D | Increment source memory pointer | |
INX B | Increment destination memory pointer | |
MOV A, C | ||
CPI 05H | Check the last number | |
JNZ BACK | If count ≠ 0, repeat | |
HLT | End of program |