8085 Simple programming Examples



The programmes are based on the Data transfer group for other group search in our search box
Let’s do a program
MVI   A,20h
STA   5050h
HLT
Here, ‘MVI A, 20h’ stores the 20h in accumulator, and STA stores the content of accumulator to to 5050.

OUTPUT
A:20
           [5050]:20
                  
1)      Store accumulator content indirect
·         STAX Rp;
·         1 byte instruction

To understand this instruction let’s take an example
LXI            D,4060h;
MVI          A,20h;
STAX        D              ;[4060]ß20h
HLT
Here, LXI loads the immediate data 4060h to register pair D ,MVI moves 20h data to  accumulator and STAX instruction  content of accumulator is stored in address pointed by register D.
So he output is
D:40  E:60
A:20                                  

[4020]: 20
2)      Input from input port
Do yourself
3)      Output to output



Do yourself      

1)      write a program to move data from register B to C,C to D and D to E.

MOV        C,B   ; moves data from register B to C
MOV        D,C    ;moves data from register C to D
MOV        D,E     ; moves data from register ram D to E
HLT                     ;stops the program

Output :
Let register B contains data 20h
B: 20h   C: 20h
D: 20h   E:  20h


2)      Write a program to store 20h in address 4040.
1st  method
LXI      H, 4030h      ; stores 4030h in HL register pair
MVI     B,20h          ; stores 20h to register B
MOV   M,B             ; moves content of register B to memory location 4040
HLT

2Nd method
MVI   A, 20h
STA    4040h
HLT

Output
B: 20         C: J J
H:40            L:30
[4040] : 20
Write a program to store the data 40H and 20H to the address 5051 and 5052 respectively.
Method 1

LXI      H, 5051h     ; Loads 5051 to HL pair
MVI    M, 40h         ; moves the data 40 h to memory location pointed by HL i.e.5051
LXI      H, 5052h     ; Loads address location 5051 to HL pair
MOV   M,20h          ; moves the data 40 h to memory location pointed by HL ie,5051
HLT                         ; stops the program

Method 2

MVI   A, 40H      ; Moves data 40H to the accumulator
STA    5051H      ; Loads the content of accumulator content to address 5051
MVI    A, 20H     ; Moves data 20H Accumulator
STA    5052H      ; Loads the content of accumulator content to address 5052
HLT

Output
[5051] : 40
[5052] : 20

2) Write the program to store the data from the memory location 2051 and 2052 to register B and C respectively.
(Before doing this program in simulator load data in memory location 2051 and 2052 yourself)
Method 1

LDA     2051H      ; load the content of address 2051 to the accumulator
MOV   B,A           ; Moves the data from Acc.  Register to B
LDA    2052H       ; load the content of address 2051 to the accumulator
MOV   C,A           ; Moves the data from Acc. to register C
HLT



Method 2

LXI         H,2051H   ;loads 2051 to HL pair
MOV      B,M          ;moves the content of memory ( i.e. address containing  in HL pair ) to B reg

No comments:

Post a Comment

its cool