You are on page 1of 6

8051 PROGRAMS

To be familiar with dyna-51 kit


A)

Entering Programme: Assemble program in memory


This command is used to write programs directly in the assembly
language (mnemonics) and using line assembler assemble it and
store it in the given memory location.
Syntax:

A b starting address

Example :

A b 9400
9400: MOV A,#04H
9402: INC A
.........
B) Viewing already entered program : Unassemble program in
memory
To view an already entered program use the command U
(Unassemble). This command is used to unassemble a given
memory block and display it on the LCD.
Syntax:

U b starting address end address


Use space bar to view the next instruction .

Example :

U b 9400 9406
9400: 7407 MOV A,#04H
9402: 04
INC A
.........
C) Entering Data in user memory area: Examine and Modify
memory content
E command allows the user to examine and modify the contents of
memory locations individually.
Syntax:

E b starting address
Use space bar key for viewing and modifying the
content of next memory location. If change in data is not
required use space bar to view/modify the next
memory locations content. Press Enter key to exit edit
mode.

Example :

E b 9400
9400: 02. new data
9400: 02. 55 space bar 30. new data

D) Display memory contents: View data/program code stored in


memory location.
Selected area of addressable memory may be accessed and
displayed by the D command.
AICTE Sponsored SDP on Understanding Embedded Systems
Conducted by Deptt. of ETCE, Tripura Institute of Technology,
Narsingarh

8051 PROGRAMS
Syntax:

D b starting address end address


Usually the contents of eight consecutive memory
locations are displayed in one line. Use ENTER key for
viewing the content of next memory locations and ESC
key to return to command prompt.

Example :

D b 1000 1020
1000: XX XX XX XX XX XX XX XX
1008: XX XX XX XX XX XX XX XX

E) Running a programme: Executing an already entered program


This command is used to execute program from a desired location
onwards.
Syntax:

GO b starting address
Use LJMP 6000H at the end of the instruction for a
finite loop program, as because it returns to the sign on
prompt.

Example :

GO b C000

AICTE Sponsored SDP on Understanding Embedded Systems


Conducted by Deptt. of ETCE, Tripura Institute of Technology,
Narsingarh

8051 PROGRAMS

Program 1: Interfacing of LED array using 8255 PPI with 8051


microcontroller.
Objective: The participants will gather hands on experience of
interfacing common output devices like LED array with
8051 microcontroller through 8255 PPI.
Background: LED array is being used extensively as output
devices in present day embedded systems. Having
exposure of this type of interfacing, the learners will get
insight view of various types display devices being used
with many types of embedded systems.
PROGRAM:
C000: MOV A, #80H
MOV DPTR, #0103H
/ Control Register Address/
MOVX @DPTR, A
MOV DPTR, #0100H
/ Port A address moved to DPTR/
MOV A, #AAH
C00B:
MOVX @DPTR, A
RLA
Delay Sub-routine can also be stored in
MOV R5, #02H
different memory location such as C0FFh and
S3: MOV R6, #FFH
could be called by instruction LCALL C0FFh
S2: MOV R7, #FFH
S1: DJNZ R7, S1
DELAY
DJNZ R6, S2
DJNZ R5, S3
C0FF:
MOV R5, #02H
S3:
MOV
R6, #FFH
LJMP C00B
S2:
S1:

MOV R7, #FFH


DJNZ R7, S1
DJNZ R6, S2
DJNZ R5, S3
RET

AICTE Sponsored SDP on Understanding Embedded Systems


Conducted by Deptt. of ETCE, Tripura Institute of Technology,
Narsingarh

8051 PROGRAMS
NB:
S1, S2 and S3 are the addresses; their value should be noted while
entering the program.

Program 2: Stepper motor control using 8051 with 8255A with


infinite loop
9400: MOV A, #80H/* Port A in Mode 0 and acting as Output*/
MOV DPTR, #0103H
MOVX @DPTR, A
MOV DPTR,#0100H
MOV A, #05H
/* 1st Sequence */
9404: MOVX @DPTR, A
LCALL C0FFH
/ * Delay subroutine calling */
nd
MOV A, #09H/* 2 Sequence */
MOVX @DPTR, A
LCALL C0FFH
MOV A, #0AH
/* 3rdSequence */
MOVX @DPTR, A
LCALL C0FFH
MOV A, #06A
/* 4thSequence */
MOVX @DPTR, A
LCALL C0FFH
LJMP 9404H
/* Infinite Loop continues */

AICTE Sponsored SDP on Understanding Embedded Systems


Conducted by Deptt. of ETCE, Tripura Institute of Technology,
Narsingarh

8051 PROGRAMS

Program 3: Stepper motor control rotating both in clock and


anticlockwise direction
9400: MOV A, #80H
MOV DPTR, #0103H
MOVX @DPTR, A
MOV DPTR,#0100H
/* For Clockwise rotation*/
MOV R4, #32H /* Count value for 360 revolution */
S4: MOV A, #05H /* 1st Sequence */
9404: MOVX @DPTR, A
LCALL C0FFH
/ * Delay subroutine calling */
nd
MOV A, #09H/* 2 Sequence */
MOVX @DPTR, A
LCALL C0FFH
MOV A, #0AH
/* 3rdSequence */
MOVX @DPTR, A
LCALL C0FFH
MOV A, #06A
/* 4thSequence */
MOVX @DPTR, A
LCALL C0FFH
DJNZ R4, S4
/* For Anticlockwise rotation*/
MOV R4, #32H /* Count value for 360 revolution */
S5: MOV A, #06H /* 1st Sequence */
9404: MOVX @DPTR, A
LCALL C0FFH
/ * Delay subroutine calling */
nd
MOV A, #0AH/* 2 Sequence */
MOVX @DPTR, A
AICTE Sponsored SDP on Understanding Embedded Systems
Conducted by Deptt. of ETCE, Tripura Institute of Technology,
Narsingarh

8051 PROGRAMS
LCALL C0FFH
MOV A, #09H
MOVX @DPTR, A
LCALL C0FFH
MOV A, #05A
MOVX @DPTR, A
LCALL C0FFH
DJNZ R4, S5
LJMP 6000H

/* 3rdSequence */

/* 4thSequence */

/* Program terminates after completion of loop

*/

Program 4: Display of arrow head using 8051.


MOV A, #03H
S1: MOV PORTA, A
LCALL DELAY
RRC A
LJUMP S1

AICTE Sponsored SDP on Understanding Embedded Systems


Conducted by Deptt. of ETCE, Tripura Institute of Technology,
Narsingarh

You might also like