Simple Programs in 8051 Assembly Language

0
3645

Here some simple assembly language programs for 8051 microcontroller are given to understand the operation of different instructions and to understand the logic behind particular program. First the statement of the program that describes what should be done is given. Then the solution is given which describes the logic how it will be done and last the code is given with necessary comments.

Statement 1: – exchange the content of FFh and FF00h

Solution: – here one is internal memory location and other is memory external location. so first the content of ext memory location FF00h is loaded in acc. then the content of int memory location FFh is saved first and then content of acc is transferred to FFh. now saved content of FFh is loaded in acc and then it is transferred to FF00h.

Mov dptr, #0FF00h ; take the address in dptr

Movx a, @dptr ; get the content of 0050h in a

Mov r0, 0FFh ; save the content of 50h in r0

Mov 0FFh, a ; move a to 50h

Mov a, r0 ; get content of 50h in a

Movx @dptr, a ; move it to 0050h

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments