Fix error in adress-determination in find_data().
This commit is contained in:
parent
ac48d2c6b7
commit
99a8dc35a7
11
src/toy.c
11
src/toy.c
@ -58,12 +58,11 @@ uint8_t get_opcode(uint16_t instruction)
|
|||||||
return opcode;
|
return opcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int find_data(uint16_t instruction)
|
uint16_t find_data(uint16_t instruction)
|
||||||
{
|
{
|
||||||
int instr;
|
uint16_t operand;
|
||||||
if(instruction > 32767) instr = -1;
|
operand = instruction & 4095;
|
||||||
else instr=instruction & 4095;
|
return operand;
|
||||||
return instr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get2compl(uint16_t value)
|
int get2compl(uint16_t value)
|
||||||
@ -78,7 +77,7 @@ int get2compl(uint16_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool execute(uint8_t op_code, int data_addr, uint16_t *ram) // jump when 1
|
bool execute(uint8_t op_code, int data_addr, uint16_t *ram) // jump if true
|
||||||
{
|
{
|
||||||
//Vorsicht: bool ops bei sigend int typs sind nach c99 undefiniert !
|
//Vorsicht: bool ops bei sigend int typs sind nach c99 undefiniert !
|
||||||
static uint16_t accu;
|
static uint16_t accu;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
int initialise_ram(uint16_t *ram, int argc, char **argv );
|
int initialise_ram(uint16_t *ram, int argc, char **argv );
|
||||||
uint8_t get_opcode(uint16_t instruction);
|
uint8_t get_opcode(uint16_t instruction);
|
||||||
int find_data(uint16_t instruction);
|
uint16_t find_data(uint16_t instruction);
|
||||||
int get2compl(uint16_t value); //not good place for something!
|
int get2compl(uint16_t value); //not good place for something!
|
||||||
bool execute(uint8_t op_code, int data_addr,uint16_t *ram);
|
bool execute(uint8_t op_code, int data_addr,uint16_t *ram);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user