URL
https://opencores.org/ocsvn/zipcpu/zipcpu/trunk
Subversion Repositories zipcpu
Compare Revisions
- This comparison shows the changes necessary to convert path
/zipcpu
- from Rev 69 to Rev 70
- ↔ Reverse comparison
Rev 69 → Rev 70
/trunk/sw/zasm/zdump.cpp
41,7 → 41,7
|
void dump_file(const char *fn) { |
const int NZIP = 4096; |
char ln[NZIP]; |
char ln[NZIP], lb[NZIP]; |
ZIPI ibuf[NZIP]; |
FILE *fp; |
int nr; |
53,7 → 53,7
printf("%s:\n", fn); |
while((nr=fread(ibuf, sizeof(ZIPI), NZIP, fp))>0) { |
for(int i=0; i<nr; i++) { |
zipi_to_string(ibuf[i], ln); |
zipi_to_string(ibuf[i], ln, lb); |
// printf("%s\n", ln); |
printf("%08x: (0x%08x %c%c%c%c) %s\n", addr++, |
ibuf[i], |
62,6 → 62,8
isgraph((ibuf[i]>> 8)&0x0ff)?((ibuf[i]>> 8)&0x0ff) : '.', |
isgraph((ibuf[i] )&0x0ff)?((ibuf[i] )&0x0ff) : '.', |
ln); |
if (lb[0]) |
printf("%28s%s\n", "", lb); |
} |
} fclose(fp); |
} |
/trunk/sw/zasm/optest.cpp
6,9 → 6,12
// |
// Purpose: A quick test of whether we can decode opcodes properly. This |
// test bypasses the assembler, and is useful when the assembler |
// isn't working. Now that we've got the assembler running, this |
// code isn't nearly as useful anymore. |
// isn't working. Now that we've got the assembler running, this code |
// isn't nearly as useful anymore. |
// |
// Even more, now that we switched instruction sets, this code is all the |
// more useless ... until updated. |
// |
// Creator: Dan Gisselquist, Ph.D. |
// Gisselquist Technology, LLC |
// |
42,10 → 45,10
|
|
void optest(const ZIPI ins) { |
char line[512]; |
char la[80], lb[80]; |
|
zipi_to_string(ins, line); |
printf("0x%08x ->\t%s\n", ins, line); |
zipi_to_string(ins, la, lb); |
printf("0x%08x ->\t%-24s\t%-24s\n", ins, la, lb); |
} |
|
int main(int argc, char **argv) { |
/trunk/sw/zasm/zopcodes.cpp
505,14 → 505,16
// printf("SBITS: %08x, %08x = %08lx\n", ins, which, |
// sbits(ins>>(which & 0x03f), (which>>8)&0x03f)); |
return sbits(ins>>(which & 0x03f), (which>>8)&0x03f); |
} else if (which &0x03f) { |
} else { // if (which &0x03f) |
return ubits(ins>>(which & 0x03f), (which>>8)&0x03f) |
+ ((which>>16)&0x0ff); |
} else |
return which; |
// } else { |
// fprintf(stderr, "Returning an uncoded %08x\n", which); |
// return which; |
} |
} |
|
void zipi_to_string(const ZIPI ins, char *line) { |
static void static_zipi_to_string(const ZIPI ins, char *line, const ZOPCODE *listp) { |
for(int i=0; i<nzoplist; i++) { |
if (((~zoplist[i].s_mask)&zoplist[i].s_val)!=0) { |
printf("Instruction %d, %s, fails consistency check\n", |
519,35 → 521,35
i, zoplist[i].s_opstr); |
assert(((~zoplist[i].s_mask)&zoplist[i].s_val)==0); |
} |
} |
for(int i=0; i<nzoplist; i++) { |
} line[0] = '\0'; |
for(int i=0; (listp[i].s_mask != 0); i++) { |
// printf("%2d: %6s %08x & %08x == %08x\n", |
// i, zoplist[i].s_opstr, ins, |
// zoplist[i].s_mask, zoplist[i].s_val); |
if ((ins & zoplist[i].s_mask) == zoplist[i].s_val) { |
sprintf(line, " %s", zoplist[i].s_opstr); |
if (zoplist[i].s_cf != OPUNUSED) { |
int bv = getbits(ins, zoplist[i].s_cf); |
if ((ins & listp[i].s_mask) == listp[i].s_val) { |
sprintf(line, "%s", listp[i].s_opstr); |
if (listp[i].s_cf != OPUNUSED) { |
int bv = getbits(ins, listp[i].s_cf); |
strcat(line, zop_ccstr[bv]); |
} sprintf(line, "%-13s", line); |
} sprintf(line, "%-11s", line); |
|
// Treat stores special |
if (strncasecmp("STO",zoplist[i].s_opstr, 3)==0) { |
int ra = getbits(ins, zoplist[i].s_ra); |
if (strncasecmp("STO",listp[i].s_opstr, 3)==0) { |
int ra = getbits(ins, listp[i].s_ra); |
strcat(line, zop_regstr[ra]); |
strcat(line, ","); |
|
if (zoplist[i].s_i != OPUNUSED) { |
if (listp[i].s_i != OPUNUSED) { |
int imv = 0; |
imv = getbits(ins, zoplist[i].s_i); |
if ((imv != 0)&&(zoplist[i].s_rb != OPUNUSED)) |
imv = getbits(ins, listp[i].s_i); |
if ((imv != 0)&&(listp[i].s_rb != OPUNUSED)) |
sprintf(&line[strlen(line)], |
"$%d", imv); |
else if (imv != 0) |
sprintf(&line[strlen(line)], |
"($%d)", imv); |
} if (zoplist[i].s_rb != OPUNUSED) { |
int rb = getbits(ins, zoplist[i].s_rb); |
} if (listp[i].s_rb != OPUNUSED) { |
int rb = getbits(ins, listp[i].s_rb); |
sprintf(&line[strlen(line)], |
"(%s)", zop_regstr[rb]); |
} |
554,30 → 556,31
|
} else { |
bool memop = (strncasecmp("LOD", |
zoplist[i].s_opstr, 3)==0); |
if (zoplist[i].s_i != OPUNUSED) { |
listp[i].s_opstr, 3)==0); |
if (listp[i].s_i != OPUNUSED) { |
int imv = 0; |
imv = getbits(ins, zoplist[i].s_i); |
if ((imv != 0)||(zoplist[i].s_rb == OPUNUSED)) |
|
imv = getbits(ins, listp[i].s_i); |
if ((imv != 0)||(listp[i].s_rb == OPUNUSED)) |
sprintf(&line[strlen(line)], |
"$%d%s", imv, |
((!memop)&&(zoplist[i].s_rb!=OPUNUSED))?"+":""); |
} if (zoplist[i].s_rb != OPUNUSED) { |
int rb = getbits(ins, zoplist[i].s_rb); |
((!memop)&&(listp[i].s_rb!=OPUNUSED))?"+":""); |
} if (listp[i].s_rb != OPUNUSED) { |
int rb = getbits(ins, listp[i].s_rb); |
if (memop) |
sprintf(&line[strlen(line)], |
"(%s)", zop_regstr[rb]); |
else |
strcat(line, zop_regstr[rb]); |
} if(((zoplist[i].s_i != OPUNUSED)||(zoplist[i].s_rb != OPUNUSED)) |
&&((zoplist[i].s_ra != OPUNUSED)||(zoplist[i].s_result != OPUNUSED))) |
} if(((listp[i].s_i != OPUNUSED)||(listp[i].s_rb != OPUNUSED)) |
&&((listp[i].s_ra != OPUNUSED)||(listp[i].s_result != OPUNUSED))) |
strcat(line, ","); |
|
if (zoplist[i].s_ra != OPUNUSED) { |
int ra = getbits(ins, zoplist[i].s_ra); |
if (listp[i].s_ra != OPUNUSED) { |
int ra = getbits(ins, listp[i].s_ra); |
strcat(line, zop_regstr[ra]); |
} else if (zoplist[i].s_result != OPUNUSED) { |
int ra = getbits(ins, zoplist[i].s_result); |
} else if (listp[i].s_result != OPUNUSED) { |
int ra = getbits(ins, listp[i].s_result); |
strcat(line, zop_regstr[ra]); |
} |
|
584,6 → 587,32
} |
break; |
} |
} if (line[0] == '\0') { |
sprintf(line, "ILL %08x", ins); |
} |
} |
|
void zipi_to_string(const ZIPI ins, char *la, char *lb) { |
static_zipi_to_string(ins, la, zoplist); |
if (lb) { |
if (ins & 0x80000000) { |
static_zipi_to_string(ins, lb, zbottomlist); |
} else lb[0] = '\0'; |
} |
} |
|
unsigned int zop_early_branch(const unsigned int pc, const ZIPI ins) { |
if ((ins & 0xf8000000) != 0x78000000) |
return pc+1; |
if ((ins & 0x07c00000) == 0x05800000) // LDI, high bit clear |
return (ins & 0x003fffff); |
if ((ins & 0x07c00000) == 0x05c00000) // LDI, high bit set |
return (ins & 0x007fffff)|0xffc00000; |
if ((ins & 0xffffe000) == 0x7bc3c000) // MOV |
return ((ins & 0x001fff)|((ins&0x01000)?0xffffe000:0))+pc+1; |
if ((ins & 0x07fc0000) == 0x00800000) // ADD, unconditional |
return ((ins & 0x03ffff)|((ins&0x020000)?0xfffc0000:0))+pc+1; |
return pc+1; |
} |
|
|
/trunk/sw/zasm/zopcodes.h
60,8 → 60,9
extern const int nzoplist; |
|
// Disassemble an opcode |
extern void zipi_to_string(const ZIPI ins, char *line); |
extern void zipi_to_string(const ZIPI ins, char *la, char *lb); |
extern const char *zop_regstr[]; |
extern const char *zop_ccstr[]; |
extern unsigned int zop_early_branch(const unsigned int pc, const ZIPI ins); |
|
#endif |