fixed some errprs
This commit is contained in:
parent
9d61e18339
commit
7b40907e6a
@ -16,18 +16,20 @@ void LogInstructionData(CpuInstructions instruction, ArgumentInfo arg1Info,
|
|||||||
*hReadA1 = malloc(sizeof(char) * 32),
|
*hReadA1 = malloc(sizeof(char) * 32),
|
||||||
*hReadA2 = malloc(sizeof(char) * 32);
|
*hReadA2 = malloc(sizeof(char) * 32);
|
||||||
|
|
||||||
sprintf(actArg1, "0x%X", arg2Val.u);
|
sprintf(actArg1, "0x%X", arg1Val.u);
|
||||||
sprintf(actArg2, "0x%X", arg2Val.u);
|
sprintf(actArg2, "0x%X", arg2Val.u);
|
||||||
|
|
||||||
switch (arg1Info)
|
switch (arg1Info)
|
||||||
{
|
{
|
||||||
case value:
|
case value:
|
||||||
|
free(hReadA1);
|
||||||
hReadA1 = "~";
|
hReadA1 = "~";
|
||||||
break;
|
break;
|
||||||
case valueInRam:
|
case valueInRam:
|
||||||
sprintf(hReadA1, "0x%X", arg1.u);
|
sprintf(hReadA1, "0x%X", arg1.u);
|
||||||
break;
|
break;
|
||||||
case valueInRegister:
|
case valueInRegister:
|
||||||
|
free(hReadA1);
|
||||||
hReadA1 = CpuRegistersHumanReadable[arg1.u];
|
hReadA1 = CpuRegistersHumanReadable[arg1.u];
|
||||||
break;
|
break;
|
||||||
case pointerInRegister:
|
case pointerInRegister:
|
||||||
@ -38,12 +40,14 @@ void LogInstructionData(CpuInstructions instruction, ArgumentInfo arg1Info,
|
|||||||
switch (arg2Info)
|
switch (arg2Info)
|
||||||
{
|
{
|
||||||
case value:
|
case value:
|
||||||
|
free(hReadA2);
|
||||||
hReadA2 = "~";
|
hReadA2 = "~";
|
||||||
break;
|
break;
|
||||||
case valueInRam:
|
case valueInRam:
|
||||||
sprintf(hReadA2, "0x%X", arg2.u);
|
sprintf(hReadA2, "0x%X", arg2.u);
|
||||||
break;
|
break;
|
||||||
case valueInRegister:
|
case valueInRegister:
|
||||||
|
free(hReadA2);
|
||||||
hReadA2 = CpuRegistersHumanReadable[arg2.u];
|
hReadA2 = CpuRegistersHumanReadable[arg2.u];
|
||||||
break;
|
break;
|
||||||
case pointerInRegister:
|
case pointerInRegister:
|
||||||
@ -111,6 +115,11 @@ void ExecuteInstruction(CpuInstructions instruction, ArgumentInfo arg1Info,
|
|||||||
break;
|
break;
|
||||||
case DIV:
|
case DIV:
|
||||||
GetAllArgVal(arg1Info, arg2Info, arg1, arg2, &actArg1, &actArg2);
|
GetAllArgVal(arg1Info, arg2Info, arg1, arg2, &actArg1, &actArg2);
|
||||||
|
if (actArg2.s == 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "DIV by 0\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
SetRegister(ACU, (r16_int){ actArg1.s / actArg2.s });
|
SetRegister(ACU, (r16_int){ actArg1.s / actArg2.s });
|
||||||
LogInstructionData(instruction, arg1Info, arg2Info, arg1, arg2, actArg1, actArg2);
|
LogInstructionData(instruction, arg1Info, arg2Info, arg1, arg2, actArg1, actArg2);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user