Fix branch handling, not to multiply by 4
This commit is contained in:
parent
37a9cf0400
commit
3b3cda2d26
@ -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++)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user