Search This Blog

Friday, August 5, 2011

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.

No comments:

Post a Comment