You can save some memory if you do "clrf porta" for mvlw b'00000' and mvwf porta Felix Centeno centella@telcel.net.ve http://www.geocities.com/CapeCanaveral/Hangar/2372/ -----Original Message----- From: Keiser Soze To: PICLIST@MITVMA.MIT.EDU Date: Martes 30 de Junio de 1998 08:51 PM Subject: Re: for beginners >Here's my first program that I wrote for the 16C84. (Sounds kind of like >a pathetic trip down memory lane doesn't it?) >It's nice and simple, assuming that you've got some LEDs connected to >portb alternate ones turn on then they all turn off, then count down >from 255 .............. I'm sure you can figure it out. > > list p=16c84 > radix hex > >;fuses set as: XT,Watchdog off,powerup timer on,code protect off >;using 4MHz osc. > >status equ 0x03 >porta equ 0x05 >portb equ 0x06 >count1 equ 0x0c >count2 equ 0x0d >count3 equ 0x0e >count4 equ 0x0f >trisa equ 0x85 >trisb equ 0x86 >rp0 equ 5 > > > >start bsf status,rp0 ;switch to bank 1 > movlw b'00000000' > movwf trisa ;set ports a&b > movwf trisb ;to all outputs (don't care about porta) > bcf status,rp0 ;switch to bank 0 > movlw b'0000000' > movwf porta ;set all > movwf portb ; outputs to zero > call alt_on > call del_0.2 > call all_off > call del_0.2 > call dec_led >no_end call alt_on > call del_2 > call alt2_on > call del_2 > call all_off > call del_2 > goto no_end > > >;-------------------- >;subroutines >;-------------------- >alt_on movlw 0aah ;put bit pattern 10101010 > movwf portb ;on leds > return > >alt2_on movlw 055h ;put bit pattern 01010101 > movwf portb ;on leds > return > >all_off clrf portb ;clear leds > return > > >dec_led movlw 0ffh ;set count1 to ffh > movwf count1 >loop1 movfw count1 ;required for repeat > movwf portb ;display current value of count1 on leds > call del_0.2 ;pause for ~0.2 seconds to allow count down to be >observed > decfsz count1,f ;dec count1, if zero return from subroutine else goto >loop1 > goto loop1 > return ;value displayed on leds will be 001h > >;---------------------- >;Delays below: >;---------------------- >del_750 movlw 0ffh ;750microseconds > movwf count2 >loop2 decfsz count2,f > goto loop2 > return > > >del_0.2 movlw 0ffh ;0.19125seconds > movwf count3 >loop3 call del_750 > decfsz count3,f > goto loop3 > return > >del_2 movlw 00ah ;1.9125seconds > movwf count4 >loop4 call del_0.2 > decfsz count4,f > goto loop4 > return >;----------------------- > end > > >______________________________________________________ >Get Your Private, Free Email at http://www.hotmail.com