-
Notifications
You must be signed in to change notification settings - Fork 0
/
decode.c
36 lines (29 loc) · 998 Bytes
/
decode.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
byte* decodeOp(word binCurrPos, byte* buffPtr, decodeType dt, bool lineNumbers, bool rawBytes) {
operation currOp = opTable[*buffPtr];
subOp currSubOp;
uint isSubOp = getSubOp(currOp, buffPtr, &currSubOp);
opUnion ou;
if(isSubOp) {
ou.subOp = currSubOp;
} else {
ou.op = currOp;
}
if(PRINT == dt){
printOp(binCurrPos, ou, buffPtr, lineNumbers, rawBytes);
printf("\n");
} else if(SCAN == dt) {
generateRelativeSymbols(binCurrPos, ou, buffPtr, isSubOp);
}
return buffPtr + (isSubOp ? currSubOp.numBytes : currOp.numBytes);
}
word decodeOpAndJump(word binCurrPos, byte * buffPtr) {
word opBytes = (buffPtr[1] << 8) + buffPtr[2];
operation currOp = opTable[*buffPtr];
char* symbol = getSymbol(opBytes);
if('\0' != symbol[0]) {
//printf("%X\t\t\t%s\t%s\n", binCurrPos, currOp.mnemonic, symbol);
} else {
//printf("%X\t\t\t%s\t%04x\n", binCurrPos, currOp.mnemonic, opBytes);
}
return opBytes;
}