misc fixes.

This commit is contained in:
Kelvin Sherlock 2019-12-14 16:17:40 -05:00
parent a793b4a0ea
commit bb43a4db93

View File

@ -157,6 +157,7 @@ namespace {
unsigned atype = 0x0000; unsigned atype = 0x0000;
unsigned kind = 0x0000; unsigned kind = 0x0000;
unsigned sav = 0; unsigned sav = 0;
unsigned lnk = 0;
bool end = false; bool end = false;
bool fas = false; bool fas = false;
int ovr = OVR_OFF; int ovr = OVR_OFF;
@ -703,9 +704,23 @@ void evaluate(label_t label, opcode_t opcode, const char *cursor) {
case OP_ADR: case OP_ADR:
atype = number_operand(cursor, local_symbol_table); atype = number_operand(cursor, local_symbol_table);
break; break;
case OP_KND: case OP_KND: {
kind = number_operand(cursor, local_symbol_table); uint32_t kind = number_operand(cursor, local_symbol_table);
if (!segments.empty())
segments.back().kind = kind;
break; break;
}
case OP_ALI: {
uint32_t align = number_operand(cursor, local_symbol_table);
// must be power of 2 or 0
if ((align & (align-1)) == 0) {
// not yet supported.
} else {
throw std::runtime_error("Bad alignment");
}
break;
}
case OP_LKV: { case OP_LKV: {
/* specify linker version */ /* specify linker version */
@ -740,6 +755,20 @@ void evaluate(label_t label, opcode_t opcode, const char *cursor) {
std::string path = path_operand(cursor); std::string path = path_operand(cursor);
process_unit(path); process_unit(path);
++lnk;
break;
}
case OP_IMP: {
/* qasm addition. import binary file. entry name is filename w/ . converted to _ */
std::string path = path_operand(cursor);
std::string name = basename(path);
for (char &c : name) {
c = std::isalnum(c) ? std::toupper(c) : '_';
}
// ...
++lnk;
break; break;
} }
@ -761,8 +790,9 @@ void evaluate(label_t label, opcode_t opcode, const char *cursor) {
if (lkv == 1 || lkv == 2 || lkv == 3) { if (lkv == 1 || lkv == 2 || lkv == 3) {
auto &seg = segments.back(); auto &seg = segments.back();
std::string base = basename(path); std::string base = basename(path);
seg.segname = std::move(base); seg.segname = base;
seg.kind = kind; seg.loadname = base;
// seg.kind = kind;
} }
if (lkv == 1) { if (lkv == 1) {
finish(); finish();
@ -848,6 +878,7 @@ void evaluate(label_t label, opcode_t opcode, const char *cursor) {
/* fast linker, only 1 file allowed */ /* fast linker, only 1 file allowed */
fas = true; fas = true;
break; break;
case OP_OVR: case OP_OVR:
ovr = ovr_operand(cursor); ovr = ovr_operand(cursor);
break; break;
@ -939,5 +970,7 @@ void process_files(int argc, char **argv) {
errx(EX_DATAERR, "%s: %s", path, ex.what()); errx(EX_DATAERR, "%s: %s", path, ex.what());
} }
} }
finish();
exit(0);
} }