add lea register (load effective address)
This commit is contained in:
@@ -51,7 +51,7 @@ uint16_t memory[UINT16_MAX];
|
|||||||
uint16_t reg[RG_COUNT];
|
uint16_t reg[RG_COUNT];
|
||||||
|
|
||||||
/* Creating instruction set opcodes */
|
/* Creating instruction set opcodes */
|
||||||
enum opcodes { // [name, value]
|
enum opcodes { // [name, 8-bit value]
|
||||||
OP_BR = 0, // branch, 0000
|
OP_BR = 0, // branch, 0000
|
||||||
OP_ADD, // add, 0001
|
OP_ADD, // add, 0001
|
||||||
OP_LD, // load, 0010
|
OP_LD, // load, 0010
|
||||||
@@ -66,7 +66,7 @@ enum opcodes { // [name, value]
|
|||||||
OP_STI, // indirect store, 1011
|
OP_STI, // indirect store, 1011
|
||||||
OP_JMP, // jump, 1100
|
OP_JMP, // jump, 1100
|
||||||
OP_RES, // reserved opcode,
|
OP_RES, // reserved opcode,
|
||||||
OP_LEA, // load effective address,
|
OP_LEA, // load effective address, 1110
|
||||||
OP_TRAP, // execute trap,
|
OP_TRAP, // execute trap,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -245,7 +245,13 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case OP_LEA:
|
case OP_LEA:
|
||||||
//{LEA};
|
uint16_t dr = (instr >> 9) & 0x7;
|
||||||
|
uint16_t PCoffset9 = sign_extend(instr & 0x1FF, 9);
|
||||||
|
|
||||||
|
reg[dr] = reg[RG_PC] + PCoffset9;
|
||||||
|
|
||||||
|
update_flags(dr);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case OP_TRAP:
|
case OP_TRAP:
|
||||||
//{TRAP};
|
//{TRAP};
|
||||||
|
|||||||
Reference in New Issue
Block a user