fix overflow indirection

This commit is contained in:
Yaossg 2024-12-08 14:34:58 +08:00
parent 3b95608233
commit 9a2a1b00be
2 changed files with 9 additions and 2 deletions

9
boot.c
View file

@ -799,7 +799,14 @@ char* store_op_of_type(int type) {
// address loaders // address loaders
// rd must be one of t0, t1, t2 // rd must be one of t0, t1, t2
void load_local_address(int rd, int slot_id) { void load_local_address(int rd, int slot_id) {
asm_addi(reg_name(rd), "sp", slot_id * 8 - 8); int offset = slot_id * 8 - 8;
char* rd_name = reg_name(rd);
if (check_itype_immediate(offset)) {
printf(" addi %s, sp, %d\n", rd_name, offset);
} else {
printf(" li %s, %d\n", rd_name, offset);
printf(" add %s, sp, %s\n", rd_name, rd_name);
}
} }
// load a non-trivial register into trivial one // load a non-trivial register into trivial one

View file

@ -1,5 +1,5 @@
int main() { int main() {
// int placeholder[1024]; int placeholder[1024];
int a = 1; int a = 1;
return (a=(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(0)))))))))))))))))))))), (a = a); return (a=(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(a+(0)))))))))))))))))))))), (a = a);
} }