;====================================================================== include common.inc udata_acs dsave_w res 1 dsave_fsr0 res 2 debugp res 1 debug_section udata 0x100 debug res 256 code ;====================================================================== ; GENERALLY USEFUL ROUTINES ;---------- read_pic_no @ ; read pic no from ID locations and return it ; W undefined pic number from ID loc 0 ; status Z undefined 1 iff master PIC ; TBLPTR* undefined points to 20001 mov_lw 0x20 mov_wf TBLPTRU clr_f TBLPTRH clr_f TBLPTRL tblrd_postinc_fixup mov_fw TABLAT return ;---------- idlocs_init @ ; read id locations and store in canonical place ; W undefined undefined ; picno undefined pic number (from 20000) ; idloc1 undefined idloc1 (from 20001) rcall read_pic_no mov_wf picno tblrd_postinc_fixup mov_fw TABLAT mov_wf idloc1 return ;---------- bitnum2bit_init @ ; populate bitnum2bit mov_lw 0x80 mov_lfsr bitnum2bit,0 init_bitnum2bit_loop rl_w mov_wf POSTINC0 bra_nn init_bitnum2bit_loop return ;---------- memory_erase @ ; picno preserved ; idloc1 preserved ; other GPRs overwritten with 0xbb mov_ff picno, FSR1L mov_ff idloc1, TABLAT mov_lfsr 0, 0 memory_erase_pageloop mov_lw 0xbb memory_erase_byteloop mov_wf POSTINC0 mov_wf POSTINC0 mov_wf POSTINC0 mov_wf POSTINC0 mov_wf POSTINC0 mov_wf POSTINC0 mov_wf POSTINC0 mov_wf POSTINC0 tst_f_ifnz FSR0L bra memory_erase_byteloop ; new page: mov_lw 0x06 xor_wfw FSR0H bra_nz memory_erase_pageloop ; done! mov_ff FSR1L, picno mov_ff TABLAT, idloc1 return ;---------- debugbyte @ ; Adds a byte to debug ; W message byte preserved ; STATUS any trashed ; all others any preserved ; Not for use in High ISR mov_ff FSR0L, dsave_fsr0 mov_ff FSR0H, dsave_fsr0+1 mov_lfsr debug, 0 mov_ff debugp, FSR0L mov_wf INDF0 inc_f debugp mov_ff dsave_fsr0, FSR0L mov_ff dsave_fsr0+1, FSR0H return include final.inc