Skip to content

Instantly share code, notes, and snippets.

@elktros
Last active November 2, 2023 14:01
Show Gist options
  • Save elktros/31a514a96562e79a289de6565d75e9ed to your computer and use it in GitHub Desktop.
Save elktros/31a514a96562e79a289de6565d75e9ed to your computer and use it in GitHub Desktop.
8051 Microcontroller Assembly Language Program for Blinking LEDs
ORG 00H ; Assembly Starts from 0000H.
; Main Program
START: MOV P1, #0XFF ; Move 11111111 to PORT1.
CALL WAIT ; Call WAIT
MOV A, P1 ; Move P1 value to ACC
CPL A ; Complement ACC
MOV P1, A ; Move ACC value to P1
CALL WAIT ; Call WAIT
SJMP START ; Jump to START
WAIT: MOV R2, #10 ; Load Register R2 with 10 (0x0A)
WAIT1: MOV R3, #200 ; Load Register R3 with 10 (0xC8)
WAIT2: MOV R4, #200 ; Load Register R4 with 10 (0xC8)
DJNZ R4, $ ; Decrement R4 till it is 0. Stay there if not 0.
DJNZ R3, WAIT2 ; Decrement R3 till it is 0. Jump to WAIT2 if not 0.
DJNZ R2, WAIT1 ; Decrement R2 till it is 0. Jump to WAIT1 if not 0.
RET ; Retu rn to Main Program
END ; End Assembly
@rami1124
Copy link

rami1124 commented Apr 3, 2022


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment