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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [cpu/] [common/] [parse.c] - Diff between revs 28 and 30

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 28 Rev 30
Line 155... Line 155...
 
 
void addlabel(char *label, unsigned long freemem)
void addlabel(char *label, unsigned long freemem)
{
{
        struct label_entry **tmp;
        struct label_entry **tmp;
 
 
        printf("adding label %s at %x\n", label, freemem);
        printf("adding label %s at 0x%x\n", label, freemem);
        tmp = &mem[freemem].label;
        tmp = &mem[freemem].label;
        for (; *tmp; tmp = &((*tmp)->next));
        for (; *tmp; tmp = &((*tmp)->next));
        *tmp = malloc(sizeof(**tmp));
        *tmp = malloc(sizeof(**tmp));
        (*tmp)->name = malloc(strlen(label)+1);
        (*tmp)->name = malloc(strlen(label)+1);
        strcpy((*tmp)->name, label);
        strcpy((*tmp)->name, label);
Line 348... Line 348...
 
 
        /* Is this item a .directive? If yes, check for some supported
        /* Is this item a .directive? If yes, check for some supported
           and then return (even if unsupported found). */
           and then return (even if unsupported found). */
        if (item[0] == DIRECTIVE_CHAR) {
        if (item[0] == DIRECTIVE_CHAR) {
                if (strcmp(item, ".align") == 0) {
                if (strcmp(item, ".align") == 0) {
                        int align = atoi(item2);
                        int align = strtoul(item2, NULL, 0);
                        if (!(freemem % align))
                        if (!(freemem % align))
                                return;
                                return;
                        freemem &= -align;
                        freemem &= -align;
                        freemem += align;
                        freemem += align;
                        return;
                        return;
                } else
                } else
 
                if (strcmp(item, ".org") == 0) {
 
                        int addr = strtoul(item2, NULL, 0);
 
                        freemem = addr;
 
                        return;
 
                } else
                if (strcmp(item, ".ascii") == 0) {
                if (strcmp(item, ".ascii") == 0) {
                        adddatastr(strstr(inputline, "\""));
                        adddatastr(strstr(inputline, "\""));
                        return;
                        return;
                } else
                } else
                if (strcmp(item, ".word") == 0) {
                if (strcmp(item, ".word") == 0) {
Line 576... Line 581...
        return;
        return;
}
}
 
 
void loadcode(char *filename)
void loadcode(char *filename)
{
{
        freemem = 0;
        freemem = MEMORY_START;
        memset(mem, 0, sizeof(mem));
        memset(mem, 0, sizeof(mem));
        identifyfile(filename);
        identifyfile(filename);
        return;
        return;
}
}
 
 
 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.