OpenCores
URL https://opencores.org/ocsvn/raptor64/raptor64/trunk

Subversion Repositories raptor64

[/] [raptor64/] [trunk/] [software/] [c64/] [source/] [Outcode.c] - Diff between revs 37 and 51

Show entire file | Details | Blame | View Log

Rev 37 Rev 51
Line 33... Line 33...
void align(int n);
void align(int n);
 
 
/*      variable initialization         */
/*      variable initialization         */
 
 
enum e_gt { nogen, bytegen, chargen, halfgen, wordgen, longgen };
enum e_gt { nogen, bytegen, chargen, halfgen, wordgen, longgen };
enum e_sg { noseg, codeseg, dataseg };
//enum e_sg { noseg, codeseg, dataseg, bssseg, idataseg };
 
 
int            gentype = nogen;
int            gentype = nogen;
int            curseg = noseg;
int            curseg = noseg;
int        outcol = 0;
int        outcol = 0;
 
 
struct oplst {
struct oplst {
        char    *s;
        char    *s;
        int     ov;
        int     ov;
        }       opl[] =
        }       opl[] =
{       {"move",op_move}, {"add",op_add}, {"addu", op_addu}, {"mov", op_mov},
{       {"move",op_move}, {"addu",op_add}, {"addu", op_addu}, {"mov", op_mov},
                {"add",op_addi}, {"sub",op_sub}, {"subu", op_subu},
                {"add",op_addi}, {"subu",op_sub}, {"subu", op_subu},
                {"subi",op_subi}, {"and",op_and},
                {"subi",op_subi}, {"and",op_and},
                {"sext8",op_sext8}, {"sext16", op_sext16}, {"sext32", op_sext32},
                {"sext8",op_sext8}, {"sext16", op_sext16}, {"sext32", op_sext32},
                {"subui",op_subui}, {"shru", op_shru}, {"divsi", op_divsi}, {"not", op_not},
                {"subui",op_subui}, {"shru", op_shru}, {"divsi", op_divsi}, {"not", op_not},
                {"addui",op_addui}, {"shr", op_shr}, {"dw", op_dw}, {"shl", op_shl}, {"shr", op_shr}, {"shru", op_shru},
                {"addui",op_addui}, {"shr", op_shr}, {"dw", op_dw}, {"shl", op_shl}, {"shr", op_shr}, {"shru", op_shru},
                {"shli", op_shli}, {"shri", op_shri}, {"shrui", op_shrui},
                {"shli", op_shli}, {"shri", op_shri}, {"shrui", op_shrui},
Line 70... Line 70...
                {"lea",op_lea}, {"asr",op_asr},
                {"lea",op_lea}, {"asr",op_asr},
                {"clr",op_clr}, {"link",op_link}, {"unlk",op_unlk},
                {"clr",op_clr}, {"link",op_link}, {"unlk",op_unlk},
                {"bra",op_bra}, {"pea",op_pea},
                {"bra",op_bra}, {"pea",op_pea},
                                {"cmp",op_cmpi}, {"tst",op_tst},
                                {"cmp",op_cmpi}, {"tst",op_tst},
                {"stop", op_stop},
                {"stop", op_stop},
                {"bmi", op_bmi},
                {"bmi", op_bmi}, {"outb", op_outb}, {"inb", op_inb}, {"inbu", op_inbu},
                                {"dc",op_dc},
                                {"dc",op_dc},
                {"",op_empty}, {"",op_asm},
                {"",op_empty}, {"",op_asm},
                {0,0} };
                {0,0} };
 
 
static char *pad(char *op)
static char *pad(char *op)
Line 187... Line 187...
    case am_adec:
    case am_adec:
                        fprintf(output,"subui\ta%d,a%d,#",ap->preg,ap->preg);
                        fprintf(output,"subui\ta%d,a%d,#",ap->preg,ap->preg);
            fprintf(output,"******[a%d]",ap->preg);
            fprintf(output,"******[a%d]",ap->preg);
            break;
            break;
    case am_indx:
    case am_indx:
 
                        if (ap->offset->i != 0)
            PutConstant(ap->offset);
            PutConstant(ap->offset);
            fprintf(output,"[%s]",RegMoniker(ap->preg));
            fprintf(output,"[%s]",RegMoniker(ap->preg));
            break;
            break;
    case am_indx2:
    case am_indx2:
 
                        if (ap->offset->i != 0)
            PutConstant(ap->offset);
            PutConstant(ap->offset);
            fprintf(output,"[%s+%s]",RegMoniker(ap->preg),RegMoniker(ap->sreg));
                        if (ap->scale==1)
 
                    fprintf(output,"[%s+%s]",RegMoniker(ap->sreg),RegMoniker(ap->preg));
 
                        else
 
                        fprintf(output,"[%s+%s*%d]",RegMoniker(ap->sreg),RegMoniker(ap->preg),ap->scale);
            break;
            break;
    case am_indx3:
    case am_indx3:
 
                        if (ap->offset->i != 0)
            PutConstant(ap->offset);
            PutConstant(ap->offset);
            fprintf(output,"[%s+%s]",RegMoniker(ap->preg),RegMoniker(ap->sreg));
            fprintf(output,"[%s+%s]",RegMoniker(ap->sreg),RegMoniker(ap->preg));
            break;
            break;
    case am_mask:
    case am_mask:
            put_mask(ap->offset);
            put_mask(ap->offset);
            break;
            break;
    default:
    default:
Line 315... Line 321...
    }
    }
}
}
 
 
void genhalf(int val)
void genhalf(int val)
{
{
        if( gentype == bytegen && outcol < 60) {
        if( gentype == halfgen && outcol < 60) {
        fprintf(output,",%d",val & 0xffffffff);
        fprintf(output,",%d",val & 0xffffffff);
        outcol += 10;
        outcol += 10;
    }
    }
    else {
    else {
        nl();
        nl();
Line 335... Line 341...
        fprintf(output,",%I64d",val);
        fprintf(output,",%I64d",val);
        outcol += 18;
        outcol += 18;
    }
    }
    else {
    else {
        nl();
        nl();
        fprintf(output,"\tdw\t%I64d",val);
        fprintf(output,"\tdh\t%I64d",val);
        gentype = wordgen;
        gentype = wordgen;
        outcol = 33;
        outcol = 33;
    }
    }
}
}
 
 
void GenerateLong(__int64 val)
void GenerateLong(__int64 val)
{       if( gentype == longgen && outcol < 56) {
{
 
        if( gentype == longgen && outcol < 56) {
                fprintf(output,",%I64d",val);
                fprintf(output,",%I64d",val);
                outcol += 10;
                outcol += 10;
                }
                }
        else    {
        else    {
                nl();
                nl();
Line 406... Line 413...
 */
 */
int     stringlit(char *s)
int     stringlit(char *s)
{
{
        struct slit *lp;
        struct slit *lp;
 
 
    ++global_flag;          /* always AllocateRegisterVars from global space. */
    ++global_flag;          /* always allocate from global space. */
    lp = (struct slit *)xalloc(sizeof(struct slit));
    lp = (struct slit *)xalloc(sizeof(struct slit));
    lp->label = nextlabel++;
    lp->label = nextlabel++;
    lp->str = litlate(s);
    lp->str = litlate(s);
    lp->next = strtab;
    lp->next = strtab;
    strtab = lp;
    strtab = lp;
Line 472... Line 479...
                fprintf(output,"\talign\t8\n");
                fprintf(output,"\talign\t8\n");
                curseg = dataseg;
                curseg = dataseg;
    }
    }
}
}
 
 

 
 No newline at end of file
 No newline at end of file
 
void seg(int sg)
 
{
 
        if( curseg != sg) {
 
                nl();
 
                switch(sg) {
 
                case bssseg:
 
                        fprintf(output,"\tbss\n");
 
                        fprintf(output,"\talign\t8\n");
 
                        break;
 
                case dataseg:
 
                        fprintf(output,"\tdata\n");
 
                        fprintf(output,"\talign\t8\n");
 
                        break;
 
                case idataseg:
 
                        fprintf(output,"\tidata\n");
 
                        fprintf(output,"\talign\t8\n");
 
                        break;
 
                case codeseg:
 
                        fprintf(output,"\tcode\n");
 
                        fprintf(output,"\talign\t16\n");
 
                        break;
 
                }
 
                curseg = sg;
 
    }
 
}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.