NOLIST ; This file is part of picide, ATA(PI) interface to PIC18 family MCUs. ; Copyright (C) 2004-5 Toby Thain, toby@telegraphics.com.au ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA LIST p=pic18f6680,r=dec,st=off #include ; we have 3328 bytes of RAM, 0x000-0xCFF inclusive secbuf equ 0x400 ; address of sector buffer, at least 2048 bytes _tmr macro N,D ; initialise TMR with 16-bit value D movlw high (D) movwf TMR#v(N)H movlw low (D) movwf TMR#v(N)L endm #ifndef UTIL_ASM extern putstrtail,putstrlist,putstrbits,psbit,putstrpc,psltemp #endif _putstr macro P ; output a NUL-terminated string beginning at PROGRAM location P ; load indirection register movlw upper (P) movwf TBLPTRU movlw high (P) movwf TBLPTRH movlw low (P) movwf TBLPTRL call putstrtail ; helper routine in util.asm endm _puts macro S ; output a NUL-terminated inline string call putstrpc dw S endm _putstrlist macro S call putstrlist dw S endm _putstrbits macro S call putstrbits dw S endm _putstrbitsp macro P movwf psltemp movlw upper (P) movwf TBLPTRU movlw high (P) movwf TBLPTRH movlw low (P) movwf TBLPTRL call psbit endm IF 0 _putstrlist macro P ; print one of a series of strings according to index ; P points to string in program memory: "zero\000one\000two\000etc" movwf psltemp movlw upper (P) movwf TBLPTRU movlw high (P) movwf TBLPTRH movlw low (P) movwf TBLPTRL call putstrlist endm _putstrbits macro P ; print strings indicated by bit vector, msb first ; P points to string in program memory: "bit7\000bit6\000bit5\000etc" movwf psltemp movlw upper (P) movwf TBLPTRU movlw high (P) movwf TBLPTRH movlw low (P) movwf TBLPTRL call putstrbits endm ENDIF _putstrd macro D ; output a NUL-terminated string beginning at DATA location D local loop,done ; load indirection register lfsr 0, D loop: movf POSTINC0,w bz done call putch bra loop done: endm _putstrswapd macro D ; output a NUL-terminated string beginning at DATA location D ; swap pairs of bytes (this is for the IDE Identify Drive ASCII data weirdness) local loop,done ; load indirection register lfsr 0, (D+1) loop: movf POSTDEC0,w bz done call putch movf POSTINC0,w bz done call putch movf POSTINC0,f movf POSTINC0,f bra loop done: endm _putchar macro c movlw c call putch endm _crlf macro _putchar '\r' _putchar '\n' endm