8051assembly language 1 Write a port programming that rotate
8051assembly language
1) Write a port programming that rotates through LED turning ON two LEDs at a time.Solution
8051 Assembly language Code:
MOV P0,#33H // The LED in OFF State and push button switches are initializing(Hez 33 in binary = 00110011).
SWSTATUS: MOV AC,P0 // Assigning port value to Accumulator.
RRC AC // Rotate Right Carry validating the Port 0 to know if switch 1 is ON or not.
JC NEXT // Jump to NXT to check if switch 2 is ON after we validatimg switch 1 is ON or not.
CLR P0.7 // If switch 1 is ON then LED turn On.
SJMP SWSTATUS // Anlayzing the switch status repeatedly.
NEXT: RRC A // Rotate Right Carry Validating the Port 0 to know if switch 1 is ON or not.
JC SWSTATUS // Goto lable SWSTATUS to validate status of switch 1 when switch 2 is OFF.
SETB P0.7 // If Switch 2 is ON then turn OFF LED.
SJMP SWSTATUS // Goto lable SWSTATUS to read status of switch 1 again.
END
