added label, branch, halt, directive to switch statement
This commit is contained in:
parent
1440ebd702
commit
da50ee27a1
@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
|
||||
typedef struct {
|
||||
dword value;
|
||||
word value;
|
||||
} a64inst_DirectiveData;
|
||||
|
||||
@ -175,26 +175,46 @@ word ldl(a64inst_instruction cI) {
|
||||
return out;
|
||||
}
|
||||
|
||||
void secondPass(a64inst_instruction instrs[], int numInstrs, st* table){
|
||||
void secondPass(a64inst_instruction instrs[], int numInstrs, st* table, word arr[]){
|
||||
//TODO:
|
||||
// iterate over instructions again, this time replacing labels
|
||||
// with values from symbol table
|
||||
// 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++) {
|
||||
a64inst_instruction cI = instrs[i];
|
||||
switch (cI.type) {
|
||||
case a64inst_DPIMMEDIATE:
|
||||
dpi(cI);
|
||||
arr[index] = dpi(cI);
|
||||
index++;
|
||||
break;
|
||||
case a64inst_DPREGISTER:
|
||||
dpr(cI);
|
||||
arr[index] = dpr(cI);
|
||||
index++;
|
||||
break;
|
||||
case a64inst_SINGLETRANSFER:
|
||||
sts(cI);
|
||||
arr[index] = sts(cI);
|
||||
index++;
|
||||
break;
|
||||
case a64inst_LOADLITERAL:
|
||||
ldl(cI);
|
||||
arr[index] = ldl(cI);
|
||||
index++;
|
||||
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:
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user