-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add tests for compiler outputs in other modes
- Loading branch information
Showing
15 changed files
with
2,249 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
section .data | ||
__printf_size: equ 16 | ||
__temp_str_1 db `%u `, 0 | ||
__temp_str_2 db `%u `, 0 | ||
__main_size: equ 96 | ||
section .text | ||
extern printf | ||
global main | ||
main: | ||
push rbp | ||
mov rbp, rsp | ||
sub rsp, __main_size | ||
mov rax, 10 | ||
mov [rsp+0], rax | ||
mov rax, 0 | ||
mov [rsp+8], rax | ||
__tmp_label_0: | ||
mov rax, [rsp + 8] | ||
mov rbx, 5 | ||
cmp rax, rbx | ||
jl __tmp_label_2 | ||
mov rax, 0 | ||
jmp __tmp_label_3 | ||
__tmp_label_2: | ||
mov rax, 1 | ||
__tmp_label_3: | ||
mov [rsp + 16], rax | ||
mov rax, [rsp + 16] | ||
cmp rax, 0 | ||
je __tmp_label_1 | ||
mov rax, 2 | ||
mov [rsp+24], rax | ||
mov rax, __temp_str_1 | ||
mov [rsp + 32], rax | ||
mov rax, [rsp + 24] | ||
mov [rsp + 40], rax | ||
mov rdi, [rsp + 32] | ||
mov rsi, [rsp + 40] | ||
call printf | ||
mov [rsp + 48], rax | ||
mov rax, [rsp + 8] | ||
mov rbx, 1 | ||
add rax, rbx | ||
mov [rsp + 24], rax | ||
mov rax, [rsp + 24] | ||
mov [rsp+8], rax | ||
jmp __tmp_label_0 | ||
__tmp_label_1: | ||
mov rax, __temp_str_2 | ||
mov [rsp + 8], rax | ||
mov rax, [rsp + 0] | ||
mov [rsp + 16], rax | ||
mov rdi, [rsp + 8] | ||
mov rsi, [rsp + 16] | ||
call printf | ||
mov [rsp + 24], rax | ||
mov rsp, rbp | ||
pop rbp | ||
ret | ||
extern exit | ||
global _start | ||
_start: | ||
call main | ||
mov rdi, 0 | ||
call exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
TKN_VOID | ||
TKN_ID(printf) | ||
TKN_L_PAREN | ||
TKN_CHAR | ||
TKN_STAR | ||
TKN_COMMA | ||
TKN_DOTS | ||
TKN_R_PAREN | ||
TKN_SEMICOLON | ||
TKN_INT | ||
TKN_ID(main) | ||
TKN_L_PAREN | ||
TKN_R_PAREN | ||
TKN_L_BRACE | ||
TKN_INT | ||
TKN_ID(i) | ||
TKN_ASSIGN | ||
TKN_LIT_INT(10) | ||
TKN_SEMICOLON | ||
TKN_FOR | ||
TKN_L_PAREN | ||
TKN_INT | ||
TKN_ID(i) | ||
TKN_ASSIGN | ||
TKN_LIT_INT(0) | ||
TKN_SEMICOLON | ||
TKN_ID(i) | ||
TKN_LT | ||
TKN_LIT_INT(5) | ||
TKN_SEMICOLON | ||
TKN_ID(i) | ||
TKN_ASSIGN | ||
TKN_ID(i) | ||
TKN_PLUS | ||
TKN_LIT_INT(1) | ||
TKN_R_PAREN | ||
TKN_L_BRACE | ||
TKN_INT | ||
TKN_ID(i) | ||
TKN_ASSIGN | ||
TKN_LIT_INT(2) | ||
TKN_SEMICOLON | ||
TKN_ID(printf) | ||
TKN_L_PAREN | ||
TKN_LIT_STR(%u ) | ||
TKN_COMMA | ||
TKN_ID(i) | ||
TKN_R_PAREN | ||
TKN_SEMICOLON | ||
TKN_R_BRACE | ||
TKN_ID(printf) | ||
TKN_L_PAREN | ||
TKN_LIT_STR(%u ) | ||
TKN_COMMA | ||
TKN_ID(i) | ||
TKN_R_PAREN | ||
TKN_SEMICOLON | ||
TKN_R_BRACE | ||
TKN_EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Program( | ||
FunctionDecl( | ||
Name: | ||
printf | ||
Returns: | ||
Type(TKN_VOID) | ||
ParamTypes: | ||
Type(TKN_CHAR*) | ||
) | ||
Function( | ||
Name: | ||
main | ||
Returns: | ||
Type(TKN_INT) | ||
Params: | ||
Statements: | ||
VarDecl(i): | ||
Type(TKN_INT) | ||
Value: | ||
Literal(Type: 34, Value: 10) | ||
For( | ||
Init: | ||
VarDecl(i): | ||
Type(TKN_INT) | ||
Value: | ||
Literal(Type: 34, Value: 0) | ||
Cond: | ||
BinaryOp(Op: 66) | ||
Left: | ||
Variable(i) | ||
Right: | ||
Literal(Type: 34, Value: 5) | ||
Act: | ||
Assign(i): | ||
Value: | ||
BinaryOp(Op: 72) | ||
Left: | ||
Variable(i) | ||
Right: | ||
Literal(Type: 34, Value: 1) | ||
Body: | ||
CompoundStatement | ||
VarDecl(i): | ||
Type(TKN_INT) | ||
Value: | ||
Literal(Type: 34, Value: 2) | ||
FunctionCall(Name: printf) | ||
Args: | ||
Literal(Type: 33, Value: %u ) | ||
Variable(i) | ||
FunctionCall(Name: printf) | ||
Args: | ||
Literal(Type: 33, Value: %u ) | ||
Variable(i) | ||
) | ||
) |
Oops, something went wrong.