Skip to content

Commit 74eed5d

Browse files
author
黄安妮
committed
changed the assembler.c for main function
1 parent 5d58de3 commit 74eed5d

File tree

7 files changed

+13
-12
lines changed

7 files changed

+13
-12
lines changed

Diff for: README.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Sysy
22

3-
[![Build Status]](https://github.com/WideSu/Compiler)
4-
53
An educational foray into compiler writing. Written in C, compiling C
64
to Arm-v7 assembly
75
([ARM assembler in Raspberry Pi](https://thinkingeek.com/arm-assembler-raspberry-pi/),

Diff for: assembly.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void write_footer(FILE *out) {
104104
//emit_function_declaration(out, "_start");
105105
//emit_function_prologue(out);
106106
emit_header(out, " .global main");
107-
emit_instr(out, "call", "main");
107+
emit_header(out, "main:");
108108
emit_instr(out, "mov", "r0, #0");
109109
emit_instr(out, "bx", "lr");
110110
}
@@ -187,7 +187,7 @@ void write_syntax(FILE *out, Syntax *syntax, Context *ctx) {
187187
emit_return(out);
188188

189189
} else if (syntax->type == FUNCTION_CALL) {
190-
emit_instr_format(out, "call", syntax->function_call->function_name);
190+
//emit_instr_format(out, "call", syntax->function_call->function_name);
191191

192192
} else if (syntax->type == IF_STATEMENT) {
193193
IfStatement *if_statement = syntax->if_statement;

Diff for: assembly.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <stdio.h>
22
#include "syntax.h"
33

4-
#ifndef BABYC_ASSEMBLY_HEADER
5-
#define BABYC_ASSEMBLY_HEADER
4+
#ifndef SYSY_ASSEMBLY_HEADER
5+
#define SYSY_ASSEMBLY_HEADER
66

77
void emit_header(FILE *out, char *name);
88

Diff for: environment.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <stdlib.h>
22

3-
#ifndef BABYC_ENV_HEADER
4-
#define BABYC_ENV_HEADER
3+
#ifndef SYSY_ENV_HEADER
4+
#define SYSY_ENV_HEADER
55

66
typedef struct VarWithOffset {
77
char *var_name;

Diff for: list.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef BABYC_LIST_HEADER
2-
#define BABYC_LIST_HEADER
1+
#ifndef SYSY_LIST_HEADER
2+
#define SYSY_LIST_HEADER
33

44
typedef struct List {
55
int size;

Diff for: run_tests.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ int run_test(char *test_program_name) {
7171
}
7272

7373
int main() {
74-
DIR *test_dir = opendir("test_programs");
74+
DIR *test_dir = opendir("tests");
7575

7676
if (test_dir == NULL) {
77-
printf("Could not open test_programs directory!");
77+
printf("Could not open tests directory!");
7878
return 1;
7979
}
8080

Diff for: tests/00_main.s

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
int main(){
2+
return 0;
3+
}

0 commit comments

Comments
 (0)