Added more instructions for the parser to emit and refactored the code in doing so.
This commit is contained in:
+33
-4
@@ -32,15 +32,15 @@ void Disassemble(unsigned char image[HIGHMEMORY]) {
|
||||
|
||||
if (masked) {
|
||||
IsRegisterPattern(instruction & 0x07, parameter1);
|
||||
unsigned char parameter = instruction & 0x18;
|
||||
unsigned char parameterType = instruction & 0x18;
|
||||
|
||||
if (!parameter) {
|
||||
if (!parameterType) {
|
||||
IsRegisterPattern(Image[position], parameter2);
|
||||
} else if (parameter == CONSTMASK) {
|
||||
} else if (parameterType == CONSTMASK) {
|
||||
snprintf(parameter2, sizeof(char) * 31, "%d", Image[position + 1] + Image[position + 2]);
|
||||
position += 3;
|
||||
}
|
||||
else if (parameter == ADDRESSMASK) {
|
||||
else if (parameterType == ADDRESSMASK) {
|
||||
snprintf(parameter2, sizeof(char) * 31, "[%#04X]", Image[position + 1] + Image[position + 2]);
|
||||
position += 3;
|
||||
}
|
||||
@@ -66,6 +66,35 @@ void Disassemble(unsigned char image[HIGHMEMORY]) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int parameter = Image[position + 1] + Image[position + 2];
|
||||
|
||||
switch(instruction) {
|
||||
case 0:
|
||||
printf("NOP\n");
|
||||
position++;
|
||||
break;
|
||||
case 1:
|
||||
printf("JZ [%#04X]\n", parameter);
|
||||
position += 3;
|
||||
break;
|
||||
case 2:
|
||||
printf("INT %d\n", Image[position + 1] + Image[position + 2]);
|
||||
position += 3;
|
||||
break;
|
||||
case 3:
|
||||
printf("YLD\n");
|
||||
position++;
|
||||
break;
|
||||
case 4:
|
||||
printf("RET\n");
|
||||
position++;
|
||||
break;
|
||||
default:
|
||||
position++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
instruction = Image[position];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user