added label, branch, halt, directive to switch statement
This commit is contained in:
parent
1440ebd702
commit
da50ee27a1
@ -1,5 +1,5 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
dword value;
|
word value;
|
||||||
} a64inst_DirectiveData;
|
} a64inst_DirectiveData;
|
||||||
|
|||||||
@ -175,26 +175,46 @@ word ldl(a64inst_instruction cI) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void secondPass(a64inst_instruction instrs[], int numInstrs, st* table){
|
void secondPass(a64inst_instruction instrs[], int numInstrs, st* table, word arr[]){
|
||||||
//TODO:
|
//TODO:
|
||||||
// iterate over instructions again, this time replacing labels
|
// iterate over instructions again, this time replacing labels
|
||||||
// with values from symbol table
|
// with values from symbol table
|
||||||
// after a line has had all the values replaced, assemble it and append
|
// after a line has had all the values replaced, assemble it and append
|
||||||
|
int index = 0;
|
||||||
|
int lbl = 0;
|
||||||
for (int i=0; i<numInstrs; i++) {
|
for (int i=0; i<numInstrs; i++) {
|
||||||
a64inst_instruction cI = instrs[i];
|
a64inst_instruction cI = instrs[i];
|
||||||
switch (cI.type) {
|
switch (cI.type) {
|
||||||
case a64inst_DPIMMEDIATE:
|
case a64inst_DPIMMEDIATE:
|
||||||
dpi(cI);
|
arr[index] = dpi(cI);
|
||||||
|
index++;
|
||||||
break;
|
break;
|
||||||
case a64inst_DPREGISTER:
|
case a64inst_DPREGISTER:
|
||||||
dpr(cI);
|
arr[index] = dpr(cI);
|
||||||
|
index++;
|
||||||
break;
|
break;
|
||||||
case a64inst_SINGLETRANSFER:
|
case a64inst_SINGLETRANSFER:
|
||||||
sts(cI);
|
arr[index] = sts(cI);
|
||||||
|
index++;
|
||||||
break;
|
break;
|
||||||
case a64inst_LOADLITERAL:
|
case a64inst_LOADLITERAL:
|
||||||
ldl(cI);
|
arr[index] = ldl(cI);
|
||||||
|
index++;
|
||||||
break;
|
break;
|
||||||
|
case a64inst_DIRECTIVE:
|
||||||
|
arr[index] = cI.data.DirectiveData.value;
|
||||||
|
index++;
|
||||||
|
break;
|
||||||
|
case a64inst_HALT:
|
||||||
|
arr[index] = 69*(2^25);
|
||||||
|
index++;
|
||||||
|
break;
|
||||||
|
case a64inst_LABEL:
|
||||||
|
lbl++;
|
||||||
|
break;
|
||||||
|
case a64inst_BRANCH:
|
||||||
|
arr[index] = assembleBranch(&cI, table, lbl);
|
||||||
|
index++;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user