Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   assembly code plz help very urgent (http://www.go4expert.com/forums/assembly-code-plz-help-urgent-t21984/)

mail866 3May2010 16:27

assembly code plz help very urgent
 
Modify the following assembly code such that input pin of PORTA is RA2(04h).
Now pin number 4 wire should connected to pin no 1 RA2 as input=5v.
then write the code so that it check each pin of PORTA from RA0 to RA4 as it is high or low from the start and turn on the led on and off contiusoly in succession . it should check the switch if it is off or on and if its off then it should turn it on and vice versa with delay in it.

[IMG]file:///C:/DOCUME%7E1/adil/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image001.gif[/IMG]
;*****Set up the Constants****

STATUS equ 03h ;Address of the STATUS register
TRISA equ 85h ;Address of the tristate register for port A
PORTA equ 05h ;Address of Port A
COUNT1 equ 08h ;First counter for our delay loops
COUNT2 equ 09h ;Second counter for our delay loops

;****Set up the port****

bsf STATUS,5 ;Switch to Bank 1
movlw 01h ;Set the Port A pins:
movwf TRISA ;bit 1to output, bit 0 to input.
bcf STATUS,5 ;Switch back to Bank 0

;****Turn the LED on****

Start movlw 02h ;Turn the LED on by first putting it
movwf PORTA ;into the w register and then on the port


;****Check if the switch is closed


BTFSC PORTA,0 ;Get the value from PORT A
;BIT 0. If it is a zero
call Delay ;a zero, carry on as normal.
;If is is a 1, then add an
;extra delay routine

;****Add a delay

call Delay

;****Delay finished, now turn the LED off****

movlw 00h ;Turn the LED off by first putting it
movwf PORTA ;into the w register and then on the port

;****Check if the switch is still closed

BTFSC PORTA,0 ;Get the value from PORT A
;BIT 0. If it is a zero,
call Delay ;carry on as normal.
;If is a 1, then add an
;extra delay routine

;****Add another delay****

call Delay

;****Now go back to the start of the program

goto Start ;go back to Start and turn LED on again

;****Here is our Subroutine

Delay

Loop1 decfsz COUNT1,1 ;This second loop keeps the LED
goto Loop1 ;turned off long enough for us to
decfsz COUNT2,1 ;see it turned off
goto Loop1 ;
return

;****End of the program****

end ;Needed by some compilers, and also
;just in case we miss the goto instruction.


All times are GMT +5.5. The time now is 01:48.