At 09:29 16/05/97 -0400, you wrote: >I have seen a couple of tips and tricks on PIC programming that I am >looking for again.. > >#1 A routine to clear all RAM on startup (16F84) > >#2 A routine for saving and restoring W,STATUS, etc.. during interrupts.. > >I suppose I could come up with some on my own... >But who wants to re-invent the wheel.. (especialy this early in the >morning...) >othrwrld@cdc.net = business. >jebrown@cdc.net = me. > Here your answer, these routines has been already posted many times and you will find an example in UMPS Demo Software (http://idls.izarbel.tm.fr/entp/techer/P01.HTM) : 1# A routine to clear all RAM on startup (16F84) Be carreful, don't forget there is some critical registers at address 0..3 and other. Don't forget to make a switch bank if you need to erase memory after $80 Indirect equ $00 TCount equ $0C StartAdr equ $10 ; Begining address to start CLEAR NbLocation equ 5 ; Number of location to erase movlw StartAdr ; Load FSR with start location movwf FSR movlw NbLocation ; Load TCount with the number movwf TCount ; of location to clear ClrLoop: clrf Indirect ; Clear Indirectly the location incf FSR ; Add 1 to FSR decfsz TCount ; Is there is again something to do ? goto ClrLoop 2# A routine for saving and restoring W,STATUS INTW equ $0C ; Memory location to save W and Status INTStatus equ $0D IntrStart: movwf INTW ; Save W and Status registers swapf STATUS,W movwf INTStatus #### Clear your INT flag if it's necessary bcf INTCON,T0IF ; Clear TIMER 0 Int flag #### Do what the INT program is expecting to do ! IntrEnd: swapf INTStatus,W ; Restore W and Status registers movwf STATUS swapf INTW swapf INTW,W retfie Hope this help you, Philippe. +------------------------------------------------------------+ | Virtual Micro Design | | | | Try UMPS: the last genereation of microcontroller simulator| | | | E-Mail: p.techer@idls.izarbel.tm.fr | | WEB: http://idls.izarbel.tm.fr/entp/techer/P01.HTM | +------------------------------------------------------------+