tests and fixes
This commit is contained in:
parent
4dc291b27e
commit
d1d1c88934
2 changed files with 18 additions and 11 deletions
11
boot.c
11
boot.c
|
@ -1033,7 +1033,7 @@ int asm_sub(int lhs, int rhs) {
|
|||
exit(1);
|
||||
}
|
||||
int diff = asm_rr(TYPE_INT, "sub", lhs, rhs);
|
||||
_asm_ri("slli", diff, diff, log_step_of(lhs_type));
|
||||
_asm_ri("srai", diff, diff, log_step_of(lhs_type));
|
||||
return diff;
|
||||
}
|
||||
if (type1) {
|
||||
|
@ -1818,7 +1818,7 @@ void parse_global_variable(int id, const char* name, int type) {
|
|||
printf("%s:\n", name);
|
||||
if (token_type == TOKEN_ASSIGN) {
|
||||
expect_token(TOKEN_NUMBER);
|
||||
printf(" .word %d\n", token_data);
|
||||
printf(" .dword %d\n", token_data);
|
||||
} else if (token_type == TOKEN_BRACKET_LEFT) {
|
||||
if (type & TYPE_PTR_MASK) {
|
||||
eprintf("array of pointers is not supported\n");
|
||||
|
@ -1827,14 +1827,11 @@ void parse_global_variable(int id, const char* name, int type) {
|
|||
expect_token(TOKEN_NUMBER);
|
||||
int size = token_data;
|
||||
expect_token(TOKEN_BRACKET_RIGHT);
|
||||
int array_size = 4 * size;
|
||||
if (type == TYPE_CHAR) {
|
||||
array_size = size;
|
||||
}
|
||||
int array_size = type == TYPE_CHAR ? size : 4 * size;
|
||||
printf(" .zero %d\n", array_size);
|
||||
declare_global(id, MARKER_ARRAY, type);
|
||||
} else {
|
||||
printf(" .zero %d\n", 4);
|
||||
printf(" .zero %d\n", 8);
|
||||
unget_token();
|
||||
}
|
||||
expect_token(TOKEN_SEMICOLON);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue