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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [zparser.cpp] - Diff between revs 69 and 89

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

Rev 69 Rev 89
Line 236... Line 236...
} ZIPI  ZPARSER::op_divs(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
} ZIPI  ZPARSER::op_divs(ZIPCOND cnd, ZIPIMM imm, ZIPREG a) const {
        return IMMOP(ZIPO_DIVS, cnd, imm, a);
        return IMMOP(ZIPO_DIVS, cnd, imm, a);
}
}
 
 
ZPARSER::ZIPIMM ZPARSER::immediate(const ZIPI a) {
ZPARSER::ZIPIMM ZPARSER::immediate(const ZIPI a) {
        ZIPOP   op((ZIPOP)((a>>25)&0x012));
        ZIPOP   op((ZIPOP)((a>>22)&0x01f));
        ZIPIMM  imm;
        ZIPIMM  imm;
 
 
        switch(op) {
        switch(op) {
                case ZIPO_MOV:
                case ZIPO_MOV:
                        imm = (a & 0x0fff); if (a&0x1fff) imm |= -0x1000; break;
                        imm = (a & 0x0fff); if (a&0x1fff) imm |= -0x1000; break;
Line 252... Line 252...
                        imm = (a & 0x0ffff);   break;
                        imm = (a & 0x0ffff);   break;
                default:
                default:
                        if (a & 0x040000) {
                        if (a & 0x040000) {
                                imm = (a&0x3fff);
                                imm = (a&0x3fff);
                                if (a&0x2000) imm |= -0x02000;
                                if (a&0x2000) imm |= -0x02000;
                                if (imm != 0)
 
                                        return false;
 
                        } else {
                        } else {
                                imm = (a&0x3ffff);
                                imm = (a&0x3ffff);
                                if (a&0x20000)
                                if (a&0x20000)
                                        imm |= -0x20000;
                                        imm |= -0x20000;
                        }
                        }
Line 269... Line 267...
bool    ZPARSER::can_merge(const ZIPI a, const ZIPI b) {
bool    ZPARSER::can_merge(const ZIPI a, const ZIPI b) {
        // 1. Can't merge anything that's already merged
        // 1. Can't merge anything that's already merged
        if ((a|b) & 0x80000000)
        if ((a|b) & 0x80000000)
                return false;
                return false;
 
 
        ZIPOP   opa((ZIPOP)((a>>25)&0x012)), opb((ZIPOP)((b>>22)&0x01f));
        ZIPOP   opa((ZIPOP)((a>>22)&0x01f)), opb((ZIPOP)((b>>22)&0x01f));
        // 2. Conditions
        // 2. Conditions
        {
        {
                ZIPCOND ca((ZIPCOND)((a>>19)&0x07)),cb((ZIPCOND)((b>>19)&0x07));
                ZIPCOND ca((ZIPCOND)((a>>19)&0x07)),cb((ZIPCOND)((b>>19)&0x07));
 
 
                if ((opa == ZIPO_LDI)||(opa == ZIPO_LDIn))
                if ((opa == ZIPO_LDI)||(opa == ZIPO_LDIn))
Line 300... Line 298...
 
 
        // 4. Immediates.  If Register + Immediate, the answer is No.
        // 4. Immediates.  If Register + Immediate, the answer is No.
        ZIPIMM imma, immb;
        ZIPIMM imma, immb;
        switch(opa) {
        switch(opa) {
                case ZIPO_MOV:
                case ZIPO_MOV:
                        imma = (a & 0x0fff); if (a) return false; break;
                        imma = (a & 0x03fff); if (a) return false; break;
                case ZIPO_LDI: case ZIPO_LDIn:
                case ZIPO_LDI: case ZIPO_LDIn:
                case ZIPO_LDILO: case ZIPO_LDIHI:
                case ZIPO_LDILO: case ZIPO_LDIHI:
                        imma = immediate(a);   break;
                        imma = immediate(a);   break;
                default:
                default:
                        if (a & 0x040000) {
                        if (a & 0x040000) {

powered by: WebSVN 2.1.0

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