summaryrefslogtreecommitdiff
path: root/assemble.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2020-12-08 10:42:10 -0500
committermrb0nk500 <b0nk@b0nk.xyz>2020-12-09 11:43:33 -0500
commita232e9f691187fdb05c35c14d4152d17f4babaf5 (patch)
tree9fdf364ce91506ed4490cd95ced6355459d7e8b5 /assemble.c
parent50875a80729eaf3be2b1473e385eca1102fce4e6 (diff)
- Implemented support for the Orthogonal extension into
both the assembler, and the emulator. I finally figured out how I could get support for the Ortho extension implemented into the old assembler. The only reason for doing this, is to buy me some while I start work on the new assembler, and to help me get an idea for how to do the same in the new assembler.
Diffstat (limited to 'assemble.c')
-rw-r--r--assemble.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/assemble.c b/assemble.c
index 87d0464..91972eb 100644
--- a/assemble.c
+++ b/assemble.c
@@ -400,7 +400,7 @@ static uint8_t write_inst(uint8_t prefix, uint8_t ext_prefix, uint8_t opcode, op
}
if (isasm) {
if (dbg) {
- printf("$%04"PRIX64":\t", address);
+ printf("write_inst(): $%04"PRIX64":\t", address);
for (int i = 0; i < inst_size; i++) {
printf("%02X", ins.u8[i]);
if (i < inst_size-1) {
@@ -574,6 +574,11 @@ token *get_operands(token *t, operand *op, uint64_t address, uint8_t rs, uint8_t
got_value = 0;
}
break;
+ case TOK_CC:
+ op[0].cc = t->byte;
+ i = 3;
+ break;
+
}
if (!t) {
break;
@@ -630,7 +635,7 @@ uint64_t handle_opcode(token *t, bytecount *bc, uint8_t isasm, uint64_t address,
get_operands(t, op, address, rs, dbg);
if (dbg) {
for (int i = 0; i < 2 && op[i].type != 0xFF; i++) {
- printf("%i: op.type: %u, op.id: $%X, op.scale; $%X, op.rind[0]: $%X, op.rind[1]: $%X, op.value: $%"PRIX64"\n", i, op[i].type, op[i].id, op[i].scale, op[i].rind[0], op[i].rind[1], op[i].value);
+ printf("handle_opcode(): %i: op.type: %u, op.id: $%X, op.scale; $%X, op.rind[0]: $%X, op.rind[1]: $%X, op.value: $%"PRIX64"\n", i, op[i].type, op[i].id, op[i].scale, op[i].rind[0], op[i].rind[1], op[i].value);
}
}
uint8_t is_eind = (op[0].type == 1 && op[0].id == MEM_RIND && op[0].rind[0] == REG_E);
@@ -909,6 +914,9 @@ uint64_t handle_opcode(token *t, bytecount *bc, uint8_t isasm, uint64_t address,
if (id == TOK_EXTOP) {
opcode = ext_ortho_ops[get_ext_ortho(instr, dbg)];
}
+ if (op[0].cc != 0xFF && op[0].cc < 8) {
+ opcode |= (op[0].cc << 5);
+ }
for (int i = 0; i < 2 && op[i].type != 0xFF; i++) {
int i2 = 0;
int j = 0;
@@ -925,7 +933,7 @@ uint64_t handle_opcode(token *t, bytecount *bc, uint8_t isasm, uint64_t address,
case MEM_ZMR:
case MEM_IND:
default:
- if (of != 0xFF) {
+ if (op[i].id != MEM_IND && op[i].id != 0xFF) {
max_val = 0;
for (i2 = 8, j = 1; i2 <= 64; i2 += 8, j++) {
max_val |= ((uint64_t)1 << (i2-1));
@@ -936,9 +944,9 @@ uint64_t handle_opcode(token *t, bytecount *bc, uint8_t isasm, uint64_t address,
}
} else {
max_val = 0;
- for (i2 = 0, j = 1; i2 <= 64; i2 += 8, j++) {
+ for (i2 = 8, j = 1; i2 <= 64; i2 += 8, j++) {
max_val |= (0xFF << i2);
- if (op[i].value <= max_val) {
+ if (op[0].value <= max_val) {
opsize = j;
break;
}
@@ -966,19 +974,19 @@ uint64_t handle_opcode(token *t, bytecount *bc, uint8_t isasm, uint64_t address,
prefix |= amp[opsize-1];
}
op_size[i] = opsize;
- if (isasm /*&& dbg*/) {
- printf("op_size[%i]: %i, opsize: %u\n", i, op_size[i], opsize);
+ if (isasm && dbg) {
+ printf("handle_opcode(): op_size[%i]: %i, opsize: %u\n", i, op_size[i], opsize);
}
break;
}
}
}
}
- inst_size = write_inst(prefix, ext_prefix, opcode, op, address, op_size, isasm, /*dbg*/isasm);
+ inst_size = write_inst(prefix, ext_prefix, opcode, op, address, op_size, isasm, dbg);
address += inst_size;
bc->progsize += inst_size;
- if (isasm /*&& dbg*/) {
- printf("inst_size: $%X, bc->progsize: $%"PRIX64"\n", inst_size, bc->progsize);
+ if (isasm && dbg) {
+ printf("handle_opcode(): inst_size: $%X, bc->progsize: $%"PRIX64"\n", inst_size, bc->progsize);
}
}
return address;