FictionTools/z88dk/src/sccz80/codegen.c
/*
 * Print the header for a library function, called from the preprocessor!
 */
Print the header for a library function, called from the preprocessor!
Print the header for a library function called from the preprocessor!
void DoLibHeader(void)
{
    char filen[FILENAME_LEN + 1];
    char* incdir;
    char* segment;
    if (donelibheader)
        return;
    strncpy(filen, Filename + 1, strlen(Filename) - 2);
    filen[strlen(Filename) - 2] = '\0';
    if (1) {
        char* ptr = filen;
        if (!isalpha(*ptr) && *ptr != '_') {
            memmove(ptr + 1, ptr, strlen(ptr) + 1);
            *ptr = 'X';
        }
        while (*ptr) {
            if (!isalnum(*ptr)) {
                *ptr = '_';
            }
            ptr++;
        }
        if (ISASM(ASM_ASXX)) {
            outstr("\n\t.module\t");
        } else if (ISASM(ASM_Z80ASM)) {
            outstr("\n\tMODULE\t");
        } else {
            outstr("\n;\t module\t");
        }
        if (strlen(filen) && strncmp(filen, "<stdin>", 7)) {
            if ((segment = strrchr(filen, '/'))) 
                ++segment;
            else if ((segment = strrchr(filen, '\\'))) 
                segment++;
            else if ((segment = strrchr(filen, ':'))) 
                segment++;
            else
                segment = filen;
            outstr(segment);
        } else {
            strcpy(filen, Filenorig);
            if ((segment = strrchr(filen, '/'))) 
                ++segment;
            else if ((segment = strrchr(filen, '\\'))) 
                segment++;
            else if ((segment = strrchr(filen, ':'))) 
                segment++;
            else
                segment = filen;
            outstr("scp_"); 
            outstr(segment);
        }
        nl();
    }
    if (ISASM(ASM_ASXX)) {
        incdir = getenv("Z80_OZFILES");
        outstr("\n\n\t.include \"");
        if (incdir)
            outstr(incdir);
        outstr("z80_crt0.hdx\"\n\n");
        ol(".area _CODE\n");
        ol(".radix d\n");
        if (c_notaltreg) {
            ol(".globl\tsaved_hl");
            ol(".globl\tsaved_de");
        }
    } else if (ISASM(ASM_GNU)) {
    } else {
        outstr("\n\n\tINCLUDE \"z80_crt0.hdr\"\n\n\n");
        if (c_notaltreg) {
            ol("EXTERN\tsaved_hl");
            ol("EXTERN\tsaved_de");
        }
    }
    donelibheader = 1;
}
void DoLibHeader ( void ) { char filen [ FILENAME_LEN + 1 ] ; char * incdir ; char * segment ; if ( donelibheader ) return ; strncpy ( filen , Filename + 1 , strlen ( Filename ) - 2 ) ; filen [ strlen ( Filename ) - 2 ] = ' \0 ' ; if ( 1 ) { char * ptr = filen ; if ( ! isalpha ( * ptr ) && * ptr != ' ' ) { memmove ( ptr + 1 , ptr , strlen ( ptr ) + 1 ) ; * ptr = ' ' ; } while ( * ptr ) { if ( ! isalnum ( * ptr ) ) { * ptr = ' ' ; } ptr ++ ; } if ( ISASM ( ASM_ASXX ) ) { outstr ( " \n \t \t " ) ; } else if ( ISASM ( ASM_Z80ASM ) ) { outstr ( " \n \t \t " ) ; } else { outstr ( " \n \t \t " ) ; } if ( strlen ( filen ) && strncmp ( filen , " " , 7 ) ) { if ( ( segment = strrchr ( filen , ' ' ) ) ) ++ segment ; else if ( ( segment = strrchr ( filen , ' \\ ' ) ) ) segment ++ ; else if ( ( segment = strrchr ( filen , ' ' ) ) ) segment ++ ; else segment = filen ; outstr ( segment ) ; } else { strcpy ( filen , Filenorig ) ; if ( ( segment = strrchr ( filen , ' ' ) ) ) ++ segment ; else if ( ( segment = strrchr ( filen , ' \\ ' ) ) ) segment ++ ; else if ( ( segment = strrchr ( filen , ' ' ) ) ) segment ++ ; else segment = filen ; outstr ( " " ) ; outstr ( segment ) ; } nl ( ) ; } if ( ISASM ( ASM_ASXX ) ) { incdir = getenv ( " " ) ; outstr ( " \n \n \t \" " ) ; if ( incdir ) outstr ( incdir ) ; outstr ( " \" \n \n " ) ; ol ( " \n " ) ; ol ( " \n " ) ; if ( c_notaltreg ) { ol ( " \t " ) ; ol ( " \t " ) ; } } else if ( ISASM ( ASM_GNU ) ) { } else { outstr ( " \n \n \t \" \" \n \n \n " ) ; if ( c_notaltreg ) { ol ( " \t " ) ; ol ( " \t " ) ; } } donelibheader = 1 ; }
Print the header for a library function, called from the preprocessor!
Print the header for a library function called from the preprocessor!
/*
     * Copy filename over (obtained by preprocessor), carefully skipping
     * over the quotes!
     */ /* Compiling a program */ /* Unix */ /*DOG*/ /*Amiga*/ /* This handles files produced by a filter cpp */ /* Unix */ /*DOG*/ /*Amiga*/ /* alpha id incase tmpfile is numeric */