longa/longi directives update m/x bits.

This commit is contained in:
Kelvin Sherlock 2016-12-24 18:06:39 -05:00
parent 45d6b8b322
commit 109d3a1118
2 changed files with 40 additions and 15 deletions

View File

@ -53,8 +53,8 @@ static constexpr const int m_S = 0x0100;
static constexpr const int m_X = 0x0200; static constexpr const int m_X = 0x0200;
static constexpr const int m_Y = 0x0400; static constexpr const int m_Y = 0x0400;
static constexpr const int m_M = 0x0010; static constexpr const int m_M = 0x0020;
static constexpr const int m_I = 0x0020; static constexpr const int m_I = 0x0010;
static constexpr const int modes[] = static constexpr const int modes[] =
{ {
@ -264,7 +264,7 @@ static constexpr const int modes[] =
1 | mImmediate | m_I, // c0 cpy #imm 1 | mImmediate | m_I, // c0 cpy #imm
1 | mDPI | m_X, // c1 cmp (dp,x) 1 | mDPI | m_X, // c1 cmp (dp,x)
1 | mAbsolute, // c2 rep # 1 | mImmediate, // c2 rep #
1 | mDP | m_S, // c3 cmp ,s 1 | mDP | m_S, // c3 cmp ,s
1 | mDP, // c4 cpy <dp 1 | mDP, // c4 cpy <dp
1 | mDP, // c5 cmp <dp 1 | mDP, // c5 cmp <dp
@ -298,7 +298,7 @@ static constexpr const int modes[] =
1 | mImmediate | m_I, // e0 cpx #imm 1 | mImmediate | m_I, // e0 cpx #imm
1 | mDPI | m_X, // e1 sbc (dp,x) 1 | mDPI | m_X, // e1 sbc (dp,x)
1 | mAbsolute, // e2 sep #imm 1 | mImmediate, // e2 sep #imm
1 | mDP | m_S, // e3 sbc ,s 1 | mDP | m_S, // e3 sbc ,s
1 | mDP, // e4 cpx <dp 1 | mDP, // e4 cpx <dp
1 | mDP, // e5 sbc <dp 1 | mDP, // e5 sbc <dp
@ -375,10 +375,20 @@ void disasm(const std::vector<uint8_t> &data, unsigned &flags, unsigned &pc) {
switch(attr & 0xf000) { switch(attr & 0xf000) {
case mImmediate: printf("\t#"); break; case mImmediate: printf("\t#"); break;
case mDP: printf("\t<"); break; case mDP: printf("\t<"); break;
case mAbsolute: printf("\t|"); break; case mDPI: printf("\t(<"); break;
case mDPIL: printf("\t[<"); break;
case mRelative:
case mBlockMove:
printf("\t"); break;
// cop, brk are treated as absolute.
case mAbsolute:
if (size == 1) printf("\t");
else printf("\t|");
break;
case mAbsoluteLong: printf("\t>"); break; case mAbsoluteLong: printf("\t>"); break;
case mAbsoluteI: printf("("); break; case mAbsoluteI: printf("\t("); break;
case mDPIL: printf("[<"); break;
} }
@ -388,7 +398,7 @@ void disasm(const std::vector<uint8_t> &data, unsigned &flags, unsigned &pc) {
} }
// todo -- relative, block mode. // todo -- relative, block mode.
switch(size) { switch (size) {
case 0: break; case 0: break;
case 1: printf("$%02x", arg); break; case 1: printf("$%02x", arg); break;
case 2: printf("$%04x", arg); break; case 2: printf("$%04x", arg); break;
@ -423,11 +433,15 @@ void disasm(const std::vector<uint8_t> &data, unsigned &flags, unsigned &pc) {
switch(op) { switch(op) {
case 0xc2: // REP case 0xc2: // REP
if (arg & 0x20) flags |= m_M; flags |= (arg & 0x30);
if (arg & 0x10) flags |= m_I; break;
//if (arg & 0x10) flags |= m_I;
//if (arg & 0x20) flags |= m_M;
break;
case 0xe2: // SEP case 0xe2: // SEP
if (arg & 0x20) flags &= ~m_M; flags &= ~(arg & 0x30);
if (arg & 0x10) flags &= ~m_I; //if (arg & 0x10) flags &= ~m_I;
//if (arg & 0x20) flags &= ~m_M;
break; break;
} }

View File

@ -193,7 +193,7 @@ void dump_obj(const char *name, int fd)
std::vector<uint8_t> tmp(iter, iter + op); std::vector<uint8_t> tmp(iter, iter + op);
iter += op; iter += op;
printf("DATA: %02x\n", op); //printf("DATA: %02x\n", op);
disasm(tmp, flags, pc); disasm(tmp, flags, pc);
continue; continue;
} }
@ -230,6 +230,8 @@ void dump_obj(const char *name, int fd)
break; break;
case OP_SHR: printf(">> "); break; case OP_SHR: printf(">> "); break;
case OP_SHL: printf("<< "); break; case OP_SHL: printf("<< "); break;
case OP_ADD: printf("+ "); break;
case OP_SUB: printf("- "); break;
default: default:
printf("\n"); printf("\n");
errx(EX_DATAERR, "%s: unknown expression opcode %02x", name, op); errx(EX_DATAERR, "%s: unknown expression opcode %02x", name, op);
@ -263,21 +265,25 @@ void dump_obj(const char *name, int fd)
}; };
uint16_t size = read_16(iter); uint16_t size = read_16(iter);
printf("\t;DEBUG\n"); //printf("\t;DEBUG\n");
for (unsigned i = 0; i < size; ++i) { for (unsigned i = 0; i < size; ++i) {
uint8_t op = read_8(iter); uint8_t op = read_8(iter);
switch(op) { switch(op) {
case D_LONGA_ON: case D_LONGA_ON:
flags |= 0x20;
printf("\tlonga\ton\n"); printf("\tlonga\ton\n");
break; break;
case D_LONGA_OFF: case D_LONGA_OFF:
flags &= ~0x20;
printf("\tlonga\toff\n"); printf("\tlonga\toff\n");
break; break;
case D_LONGI_ON: case D_LONGI_ON:
flags |= 0x10;
printf("\tlongi\ton\n"); printf("\tlongi\ton\n");
break; break;
case D_LONGI_OFF: case D_LONGI_OFF:
flags &= ~0x10;
printf("\tlongi\toff\n"); printf("\tlongi\toff\n");
break; break;
case D_C_FILE: { case D_C_FILE: {
@ -314,8 +320,13 @@ void dump_obj(const char *name, int fd)
printf("\t.sect\t%d\n", section); printf("\t.sect\t%d\n", section);
break; break;
} }
case REC_ORG: {
uint32_t org = read_32(iter);
printf("\t.org\t$%04x\n", org);
break;
}
case REC_SPACE: case REC_SPACE:
case REC_ORG:
case REC_RELEXP: case REC_RELEXP:
case REC_LINE: case REC_LINE:
default: default: