
Site Search
Alternate Blinking LED Using SWAP Instruction in Assembly Language, Time Delay 0.125s

Alternate Blinking LED Using SWAP Instruction in Assembly Language, Time Delay 0.125s
;=================================================================
;Code Written by: Azhar Ahmed
; W W W . I A M T E C H N I C A L . C O M
;Crystal Frequency = 12MHz / 12 Machine Cycles = 1Mhz
;1/1MHz = 1 Microsecond
;(250 x 250 x 2 x 1Microsecond) x 1 time ACALL Delay = 0.125 Second
;=================================================================
ORG 0000H
MOV A,#11110000B ;Load 11110000B in Binary to Accumulator
BACK: MOV P1,A ;Send 11110000B to Port 1
ACALL DELAY ;Wait 0.125 Second
SWAP A ;Rotate the Low and High Nibbles in Accumulator i.e 00001111 Now
MOV P1,A ;Send the Rotated Nibbles to Port 1
ACALL DELAY ;Wait 0.125 Second
SWAP A ;Rotate the Low and High Nibbles in Accumulator i.e 11110000 Now
SJMP BACK ;Make This Operation to Run Repeatedly
DELAY:
MOV R0,#250 ;Initialize the R0 Register With an Immediate Value 250
NEXT:
MOV R1,#250 ;Load R0 With 250 Value to Repeat the Loop for 250 Times
AGAIN:
DJNZ R1,AGAIN ;Internal Loop Repeates 250 Times
DJNZ R0,NEXT ;External Loop Repeates 250 Times
RET ;Return to Caller
END ;End of .asm File
;==================================================================