How can I remember microprocessor 8085 programs?



In microprocessor’s assembly language programming, a program can be made in many ways using different addressing modes. Once you have understood the logic behind a program, you can easily do the programming. First, Understand the program, means what are the inputs and what should be the output. And then do the programming in the following manner:
  1. Write an algorithm for the program (stepwise manner).
  2. You may draw flow chart also.
  3. Now, insert instructions for each step.
For this, you will have to learn the instructions with their formats. Start with small programs like add, subtract then go to the higher level.
Example Program :
Write an ALP to perform 16-bit addition on following data 1256H and 1104H. Store the result in H and L registers.
Description:
To add the two data bytes 1256H and 1104H, first load those data bytes in general purpose registers. Then take 1 LSB data in the accumulator and add the 2 LSB data bytes. Store the result of the addition. Take the next data byte to add the 2 MSB data bytes and carry if generated from LSB addition. Store the result of the addition.
Program:
Instructions Operation
MVI B, 12H : Move data 1 MSB in reg B
MVI C, 56H : Move data 1 LSB in reg C
MVI D, 11H : Move data 2 MSB in reg D
MVI E, 04H : Move data 2 LSB in reg E
MOV A, E : Move data 2 LSB in reg A from reg E
ADD C : Add both the LSBs (A+C=A)
MOV L, A : Move the result in reg L from reg A
MOV A, D : Move data 2 MSB in reg A from reg D
ADC B : Add both the MSBs with carry (A+B+carry= A)
MOV H, A : Move the result in reg H from reg A
HLT : Stop
Note :1. The parallel program can be prepared by using instruction LXI, instead of using MVI to load the 16bit data.
2.The same 16 bit addition program can be performed directly using instruction DAD Rp, but it requires one data in HL register pair.
LXI H, 1256H : Load the first data in HL register pair
LXI B, 1104H : Load the second data in BC register pair
DAD B : HL + BC = HL
HLT : Stop

Thanks.
Next Post Previous Post
No Comment
Add Comment
comment url