/*************************************************************************** * Copyright (C) 2006 Nicolas Hadacek * * * * 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 generate xml files for kate highlighting // the original syntax file was created by Alain Gibaud #include #include const char * const DIRECTIVES[] = { "__badram", "__config", "__idlocs", "__maxram", "bankisel", "banksel", "cblock", "code", "cblock", "constant", "da", "data", "db", "de", "dt", "dw", "endm", "endc", "endw", "equ", "error", "errorlevel", "extern", "exitm", "expand", "fill", "global", "idata", "list", "local", "macro", "messg", "noexpand", "nolist", "org", "page", "processor", "pagesel", "radix", "res", "set", "space", "subtitle", "title", "udata", "udata_acs", "udata_ovr", "udata_shr", "variable", "end", 0 }; const char * const CONDITIONNALS[] = { "if", "else", "ifdef", "ifndef", "endif", "while", "include", "endw", "{", "}", 0 }; const char * const GPASM_MACROS[] = { "addcf", "b", "bc", "bz", "bnc", "bnz", "clrc", "clrz", "setc", "setz", "movfw", "negf", "skpc", "skpz", "skpnc", "skpnz", "subcf", "tstf", 0 }; const char * const CPIK_MACROS[] = { "IBZ", "IBNZ", "IBRA", "ICALL", 0 }; const char * const SFRS[] = { // #### should be extracted from dev files... "TOSU", "TOSH", "TOSL", "STKPTR", "PCLATU", "PCLATH", "PCL", "TBLPTRU", "TBLPTRH", "TBLPTRL", "TABLAT", "PRODH", "PRODL", "INTCON", "INTCON2", "INTCON3", "INDF0", "POSTINC0", "POSTDEC0", "PREINC0", "PLUSW0", "FSR0H", "FSR0L", "WREG", "INDF1", "POSTINC1", "POSTDEC1", "PREINC1", "PLUSW1", "FSR1H", "FSR1L", "BSR", "INDF2", "POSTINC2", "POSTDEC2", "PREINC2", "PLUSW2", "FSR2H", "FSR2L", "STATUS", "TMR0H", "TMR0L", "T0CON", "OSCCON", "LVDCON", "WDTCON", "RCON", "TMR1H", "TMR1L","T1CON", "TMR2", "PR2", "T2CON", "SSPBUF", "SSPADD", "SSPSTAT", "SSPCON1", "SSPCON2", "ADRESH", "ADRESL", "ADCON0", "ADCON1", "ADCON2", "CCPR1H", "CCPR1L", "CCP1CON", "CCPR2H", "CCPR2L", "CCP2CON", "PWM1CON", "ECCPAS", "CVRCON", "CMCON", "TMR3H", "TMR3L", "T3CON", "SPBRG", "RCREG", "TXREG", "TXSTA", "RCSTA", "EEADR", "EEDATA", "EECON2", "EECON1", "IPR2", "PIR2", "PIE2", "IPR1", "PIR1", "PIE1", "OSCTUNE", "TRISE", "TRISD", "TRISC", "TRISB", "TRISA", "LATE", "LATD", "LATC", "LATB", "LATA", "PORTE", "PORTD", "PORTC", "PORTB", "PORTA", "TMR0", "TMR1", "OPTION_REG", 0 }; const char * const INSTRUCTIONS[] = { "addlw", "addwf", "addwfc", "andlw", "andwf", "bcf", "bc", "bn", "bnc", "bnn", "bnov", "bnz", "bz", "bov", "bra", "bsf", "btfsc", "btg", "btfss", "call", "clrf", "clrw", "clrwdt", "comf", "cpfseq", "cpfsgt", "cpfslt", "daw", "decf", "decfsz", "dcfsnz", "goto", "incf", "incfsz", "infsnz", "iorlw", "iorwf", "lfsr", "movf", "movff", "movlb", "movlw", "movwf", "mullw", "mulwf", "negf", "nop", "option", "pop", "push", "rcall", "reset", "retfie", "retlw", "rlcf", "rlncf", "rrcf", "rrncf", "return", "rlf", "rrf", "setf", "sleep", "sublw", "subfwb", "subwf", "subwfb", "swapf", "tstfsz", "tris", "tblrd", "tblwt", "xorlw", "xorwf", 0 }; TQTextStream *initFile(TQFile &file) { if ( !file.open(IO_WriteOnly) ) qFatal("Cannot create \"%s\".", file.name().latin1()); TQTextStream *s = new TQTextStream(&file); (*s) << "" << endl; (*s) << "" << endl; (*s) << "" << endl; return s; } void addList(TQTextStream &s, const TQString &name, const char * const *items, bool upper) { s << " " << endl; for (uint i=0; items[i]; i++) { s << " " << items[i] << ""; if (upper) s << "" << TQString(items[i]).upper() << ""; s << endl; }; s <<" " << endl; } void addCommon(TQTextStream &s) { addList(s, "instructions", INSTRUCTIONS, true); s << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << endl; s << " " << endl; s << " " << endl; } void addAsmContexts(TQTextStream &s) { s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; } void endFile(TQTextStream &s) { s << " " << endl; s << "" << endl; s << endl; s << "" << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << " " << endl; s << "" << endl; s << endl; s << "" << endl; } int main(int, char **) { TQFile afile("asm-pic.xml"); TQTextStream *s = initFile(afile); (*s) << "" << endl; (*s) << endl; (*s) << "" << endl; addList(*s, "directives", DIRECTIVES, true); addList(*s, "conditionnal", CONDITIONNALS, false); addList(*s, "gpasm_macro", GPASM_MACROS, false); addList(*s, "cpik_macro", CPIK_MACROS, false); addList(*s, "sfrs", SFRS, false); addCommon(*s); addAsmContexts(*s); endFile(*s); TQFile cfile("coff-pic.xml"); s = initFile(cfile); (*s) << "" << endl; (*s) << endl; (*s) << "" << endl; addCommon(*s); (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; (*s) << " " << endl; endFile(*s); }