- /* Instruction binary format is: xxyy yzzz 0000 oooX
- * Big-Endian, X is the most significant part of Xxx.
- */
- code |= (c->opcode << 4);
-
- code |= (((uint64_t)c->operands[0].u.operand & 0xF00) >> 8);
- code |= (((uint64_t)c->operands[0].u.operand & 0x0FF) << 56);
-
- code |= ((uint64_t)c->operands[1].u.operand << 44);
-
- code |= ((uint64_t)c->operands[2].u.operand << 32);
-
- outbuf[7] = (code & 0x00000000000000FFULL);
- outbuf[6] = (code & 0x000000000000FF00ULL) >> 8;
- outbuf[5] = (code & 0x0000000000FF0000ULL) >> 16;
- outbuf[4] = (code & 0x00000000FF000000ULL) >> 24;
- outbuf[3] = (code & 0x000000FF00000000ULL) >> 32;
- outbuf[2] = (code & 0x0000FF0000000000ULL) >> 40;
- outbuf[1] = (code & 0x00FF000000000000ULL) >> 48;
- outbuf[0] = (code & 0xFF00000000000000ULL) >> 56;
+ if (ctx->arch == 5) {
+ /* Instruction binary format is: xxyyyzzz0000oooX
+ * byte-0-^ byte-7-^
+ * ooo is the opcode
+ * Xxx is the first operand
+ * yyy is the second operand
+ * zzz is the third operand
+ */
+ code |= ((uint64_t)c->operands[2].u.operand);
+ code |= ((uint64_t)c->operands[1].u.operand) << 12;
+ code |= ((uint64_t)c->operands[0].u.operand) << 24;
+ code |= ((uint64_t)c->opcode) << 36;
+ code = ((code & (uint64_t)0xFFFFFFFF00000000ULL) >> 32) |
+ ((code & (uint64_t)0x00000000FFFFFFFFULL) << 32);
+ } else if (ctx->arch == 15) {
+ code |= ((uint64_t)c->operands[2].u.operand);
+ code |= ((uint64_t)c->operands[1].u.operand) << 13;
+ code |= ((uint64_t)c->operands[0].u.operand) << 26;
+ code |= ((uint64_t)c->opcode) << 39;
+ code = ((code & (uint64_t)0xFFFFFFFF00000000ULL) >> 32) |
+ ((code & (uint64_t)0x00000000FFFFFFFFULL) << 32);
+ } else {
+ asm_error(ctx, "No emit format for arch %u",
+ ctx->arch);
+ }
+ outbuf[0] = (code & (uint64_t)0xFF00000000000000ULL) >> 56;
+ outbuf[1] = (code & (uint64_t)0x00FF000000000000ULL) >> 48;
+ outbuf[2] = (code & (uint64_t)0x0000FF0000000000ULL) >> 40;
+ outbuf[3] = (code & (uint64_t)0x000000FF00000000ULL) >> 32;
+ outbuf[4] = (code & (uint64_t)0x00000000FF000000ULL) >> 24;
+ outbuf[5] = (code & (uint64_t)0x0000000000FF0000ULL) >> 16;
+ outbuf[6] = (code & (uint64_t)0x000000000000FF00ULL) >> 8;
+ outbuf[7] = (code & (uint64_t)0x00000000000000FFULL) >> 0;