PIC lights on, Assembly Language

Assignment Help:
errorlevel -302 ;prevents error code for this chipset
__config 0x373A ;chip config PIC spec page 146
processor 16F877A ;chipset

reset code 0x00
pagesel start ;Chooses pages from goto
nop ;does nothing
goto start

;**************************************************************************
code ;LABEL
start ;Label
clrf STATUS ;clear status from regester(Z is in status regester)
clrf PORTA ;clear port A
clrf PORTB ;clear port B
movlw 0x03 ;move literal into w
movwf PORTA ;move w into f

bsf STATUS, RP0 ;bit set f status, Regestry bank 0
movlw 0x07 ;move literal into w
movwf ADCON1
clrf TRISA ;clear register TriState regestry port A
clrf TRISB ;clear register TriState regestry port B
clrf TRISD ;clear register TriState regestry port D

CLRF STATUS
;*******************************************************************************
loop ;Start a Loop function
call LCD_update ;Calls LCD_Update function
call delay ;Calls delay function for time
goto loop ;Returns to loop


LCD_update_code code ;LAbEL
LCD_update ;LABEL

;IF CONTROL
sw1 btfsc PORTB, 1
goto display1
btfsc PORTB, 0
goto display2
display1
bcf PORTB, 0x01 ;turn Off LED 2
movlw 0xF9 ;Set number 1
movwf PORTD ;move w to f set PORTD
bsf PORTB, 0x00 ;turn On LED 1
goto finish_display

sw2 btfsc PORTB, 0
goto display2
btfsc PORTB, 1
goto display3
display2
bcf PORTB, 0x00 ;turn off LED
movlw 0x24 ;Set number 2
movwf PORTD
bsf PORTB, 0x01 ;turn on LED 2
goto finish_display


sw3 btfsc PORTB, 1
goto display3
btfsc PORTB, 0
goto display4
display3
bcf PORTB, 0x04 ;turn off LED 4
movlw 0x30 ;Set number 3
movwf PORTD
bsf PORTB, 0x02 ;turn on LED 3
goto finish_display


sw4 btfsc PORTB, 0
goto display3
btfsc PORTB, 1
goto finish_display
display4
bcf PORTB, 0x02 ;turn off LED 3
movlw 0x8D ;Set number 4
movwf PORTD
bsf PORTB, 0x04 ;turn on LED 4
goto finish_display

finish_display
RETURN

;*****************************************************************
;Variables for delay function

delay_udata udata ;LABEL
x res 2 ;x reserves 2 bytes

.delay code
delay
banksel x
clrf x
movlw 20
movwf x + 1
decfsz x, 1
goto $-1
decfsz x + 1, 1
goto $-3
return

end

Related Discussions:- PIC lights on

Flow chart and pseudocode, #question.flow chart for a program to find out t...

#question.flow chart for a program to find out the number of even and odd numbers from a given series of 16-bit hexadecimal numbers.

Cache memory-microprocessor, Cache Memory Caching is a technology based...

Cache Memory Caching is a technology based on the memory subsystem of any computer. The majoraim of a cache is to accelerate the computer while keeping the cost of the computer

Assignment, Write an assembly program that adds the elements in the odd ind...

Write an assembly program that adds the elements in the odd indices of the following array. Use LOOP. What is the final value in the register?

Program to find out positive and negative numbers-assembly, Program : W...

Program : Write an assembly program to find out the number of positive numbers and negative numbers from a given series of signed numbers. Solution : Take the i th num

Program for initialize two row lcd, init_lcd                        ;(this ...

init_lcd                        ;(this initialises a 2 row lcd)     bcf     TRISA,0             ;PORTA bit 0 as an output (lcd RS pin)     bcf     TRISA,1             ;PORTA bit 1

Odd and even numbers, hi, i''m new to assembly language and my teacher told...

hi, i''m new to assembly language and my teacher told us to look for an example of the odd and even numbers program using debug.exe in ms dos as a guide since we just started. plea

AAD, AAD stand for what??

AAD stand for what??

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd