Fix branch handling, not to multiply by 4

This commit is contained in:
sBubshait 2024-06-14 20:31:08 +01:00
parent 37a9cf0400
commit 3b3cda2d26
2 changed files with 2 additions and 2 deletions

View File

@ -43,7 +43,7 @@ static symbol_table *firstPass(a64inst_instruction *instructions, int lineCount)
for (int i = 0; i < lineCount; i++) { for (int i = 0; i < lineCount; i++) {
a64inst_instruction inst = instructions[i]; a64inst_instruction inst = instructions[i];
if (inst.type == a64inst_LABEL) { if (inst.type == a64inst_LABEL) {
st_insert(table, inst.data.LabelData.label, 4 * (i - (labelCount++))); st_insert(table, inst.data.LabelData.label, (i - (labelCount++)));
} }
} }

View File

@ -49,7 +49,7 @@ int64_t signExtend(dword value, unsigned int n) {
static int getLabelOffset(symbol_table* table, char* label, int currentIndex, int n_bits) { static int getLabelOffset(symbol_table* table, char* label, int currentIndex, int n_bits) {
address target = st_get(table, label); address target = st_get(table, label);
return signExtend((unsigned int) (target - (currentIndex * 4)), n_bits); return signExtend((unsigned int) (target - currentIndex), n_bits);
} }
// Generates assembled code based on the two-pass assembly method // Generates assembled code based on the two-pass assembly method