Loading....
Coupon Accepted Successfully!

 

Simple Examples In Assembly Language Programs Of 8051 Microcontroller

 

Example : Store 8-bit immediate data (65H) into accumulator.
 

Mnemonics Opcode Comments
MOV A, #65H Store 65H into accumulator immediately

 

Example : Load 42H and 55H in Registers R0 and R1 respectively.
 
Mnemonics Opcode Comments
MOV R0, #42H Load 42H in R0 register
MOV R1, #55H Load 55H in R1 register
 
Example : Place the contents of external memory location 8000H into accumulator.
 
Mnemonics Opcode Comments
MOV DPTR, #8000H Load 8000H in data pointer register immediately
MOVX A, @DPTR Copy the content of external memory location 8000H into accumulator
 
Example : Load 45H in external memory location 8000 H.
Mnemonics Opcode Comments
MOV DPTR, #8000H Load 8000H in data pointer register immediately
MOV A, #45H Load 45H into accumulator
MOVX @DPTR,A Copy the content of Accumulator (45H) into external memory location 8000H
 
Example : Write program instructions to load a byte in memory location 9000H and increment the contents of the memory location.
 
Mnemonics Opcode Comments
MOV DPTR, #9000H Load 9000H in data pointer register immediately
MOV A, #48H Load 48H into accumulator
MOVX @DPTR, A Copy the content of Accumulator 48H into external memory location 9000H
INC A Increment accumulator
MOVX @DPTR, A Load 49H, i.e., the content of Accumulator into external memory location 9000H
 
Example : Store 01H, 02H, 03H and 04H in register R0, R1, R2 and R3 respectively and exchange data stored in Reg. R0 with R1 and data in Reg. R2 with R3.
 
Mnemonics Opcode Comments
MOV R0, #01H Load 01H in R0 register immediately.
MOV R1, #02H Load 02H in R1 register immediately.
MOV R2, #03H Load 03H in R2 register immediately.
MOV R3, #04H Load 04H in R3 register immediately.
MOV A, R0H Copy the content of R0 into accumulator.
XCH A, R1 The content of accumulator and register R1 are exchanged.
MOV R0, A The content of accumulator into R0 register.
MOV A, R2 Copy the content of R2 into accumulator.
XCH A, R3 The content of accumulator and register R3 are exchanged.
MOV R2, A The content of accumulator into R2 register.

Program for A/D Converter Interfacing with 8051 Microcontroller

The step of A/D converter is as follows:


Step-1
 The start of conversion, SC signal send to pin WR to start the conversion.


Step-2
 INTR pin is connected with end of conversion EOC signal. Keep monitoring the INTR pin to check end of conversion. If INTR is high, keep polling until it becomes low.


Step-3
 When the INTR is low, the A/D conversion is completed and the ADC0804 send a high-to-low pulse to the RD pin.

 

Microcontroller Based Traffic Control

Table: Traffic movement and status of ports

 
Traffic movement Status of Port A Status of Port B Status of Port C
North to South traffic movement 21H 04H F9H
North to South traffic movement be ready to stop and East to West traffic be ready for start 12H 04H 09H
East to West traffic movement 0CH 27H 89H
East to West traffic movement be ready to stop and South to North traffic be ready for start 94H 20H 08H
South to North traffic movement 64H 3CH 18H
South to North traffic movement be ready to stop and West to East traffic be ready for start A4H 00H 14H
West to East traffic movement 24H D0H 93H
West to East traffic movement be ready to stop and North to South traffic be ready for start 22H 00H 85H

 

Traffic light control

Microcontroller-Based Stepper Motor Control

 

Four-Phase stepper motor windings
 
 




Test Your Skills Now!
Take a Quiz now
Reviewer Name