
Site Search
Demonstration of Assembly Language Instruction SETB and CPL, LED's 'ON' and 'OFF' for 1 Second

Demonstration of Assembly Language Instruction SETB and CPL, LED's 'ON' and 'OFF' for 1 Second
;=================================================================
;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 8 times ACALL Delay = 1 Second
;=================================================================
ORG 0000H
SETB P1.0 ;Set Port Bit 0 of P1 to HIGH
SETB P1.1 ;Set Port Bit 1 of P1 to HIGH
SETB P1.2 ;Set Port Bit 2 of P1 to HIGH
SETB P1.3 ;Set Port Bit 3 of P1 to HIGH
SETB P1.4 ;Set Port Bit 4 of P1 to HIGH
SETB P1.5 ;Set Port Bit 5 of P1 to HIGH
SETB P1.6 ;Set Port Bit 6 of P1 to HIGH
SETB P1.7 ;Set Port Bit 7 of P1 to HIGH
BACK:ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
ACALL DELAY ;WAIT 0.125 Second
CPL P1.0 ;Complement Bit 0 of Port 1,High-to-Low
CPL P1.1 ;Complement Bit 1 of Port 1,High-to-Low
CPL P1.2 ;Complement Bit 2 of Port 1,High-to-Low
CPL P1.3 ;Complement Bit 3 of Port 1,High-to-Low
CPL P1.4 ;Complement Bit 4 of Port 1,High-to-Low
CPL P1.5 ;Complement Bit 5 of Port 1,High-to-Low
CPL P1.6 Complement Bit 6 of Port 1,High-to-Low
CPL P1.7 ;Complement Bit 7 of Port 1,High-to-Low
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
;================================================================================