WAP in assembly language to toggle bits of port 1 with a delay which depends on the value of a number in R0



ORG 0H ; START PROGRAM FROM 0H
START:  MOV A, #O ;
MOV P1, A ;
MOV R0, #30H ;
ACALL DELAY ; CALL DELAY
CPL A ; COMPLEMENT A TO TOGGLE
MOV P1, A ; TOGGLE P1 BY TRANSFERING A
MOV R0, #OFFH ; CHANGE R0 VALUE TO CHANGE DELAY
ACALL DELAY ; CALL DELAY WITH DIFFERENT R0
SJMP START ; JUMP BACK TO START




DELAY: NOP ; DELAY SUBROUTINE
LOOP: DJNZ RO, LOOP ;
RET ;


END ;
; NOTE THE PROGRAM RUNS CONTINUOSLY TOGGLEING PORT 1 REPEATEDLY
; QUESTION ARISES WHERE ONE NEED TO USE CONTINUOUS TOGGLEING OF
; PORTS. WELL SIMPLE APPLICATION INCLUDES BLINKING LEDS ON/OFF
; WITH ON TIME LARGER THAN OFF TIME.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s