diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/tpc.y | 45 |
1 files changed, 17 insertions, 28 deletions
@@ -42,40 +42,29 @@ static int status = GLOBAL; | |||
42 | %precedence ELSE | 42 | %precedence ELSE |
43 | 43 | ||
44 | %% | 44 | %% |
45 | Prog:{printf("section .data\n"); | 45 | Prog:{printf("extern printf\n"); |
46 | printf("format_entier db \"%%d \n\", 10,0"); | 46 | printf("section .data\n"); |
47 | printf("section .bss\nsection .text\nglobal _start\n"); | 47 | printf("format_int db \"%%d \\n\",10,0\n\n"); |
48 | printf("print:\n"); | 48 | printf("section .bss\nsection .text\n\nglobal _start\n"); |
49 | printf("print: ;print needs an argument in rax\n\n"); | ||
49 | printf("push rbp\n"); | 50 | printf("push rbp\n"); |
50 | printf("mov rbp, rsp\n"); | 51 | printf("mov rbp, rsp\n"); |
51 | |||
52 | printf("push rax\n"); | ||
53 | printf("push rcx\n"); | ||
54 | printf("push rdx\n"); | ||
55 | printf("push rdi\n"); | ||
56 | printf("push rsi\n"); | 52 | printf("push rsi\n"); |
57 | printf("push r8\n"); | 53 | printf("mov rsi, rax\n"); |
58 | 54 | printf("mov rdi, format_int\n"); | |
59 | printf("mov r8, rdx \n"); | 55 | printf("mov rax, 0\n"); |
60 | printf("mov rcx, rcx\n"); | 56 | printf("call printf WRT ..plt\n"); |
61 | printf("mov rdx, rbx\n"); | ||
62 | printf(" mov rdi, format_entier\n"); | ||
63 | printf(" mov rax, 0\n"); | ||
64 | printf(" call printf WRT ..plt\n"); | ||
65 | |||
66 | printf("pop r8\n"); | ||
67 | printf("pop rsi\n"); | 57 | printf("pop rsi\n"); |
68 | printf("pop rdi\n"); | ||
69 | printf("pop rdx\n"); | ||
70 | printf("pop rcx\n"); | ||
71 | printf("pop rax\n"); | ||
72 | |||
73 | printf("pop rbp\n"); | 58 | printf("pop rbp\n"); |
74 | printf("ret\n"); | 59 | printf("ret\n"); |
60 | printf("\n_start:\n"); | ||
75 | } | 61 | } |
76 | DeclConsts DeclVars DeclFoncts { | 62 | DeclConsts DeclVars DeclFoncts |
77 | 63 | { | |
78 | glo_display_table();} | 64 | printf("mov rax,60 \n"); |
65 | printf("mov rdi,0 \n"); | ||
66 | printf("syscall \n"); | ||
67 | } | ||
79 | ; | 68 | ; |
80 | DeclConsts: | 69 | DeclConsts: |
81 | DeclConsts CONST ListConst ';' | 70 | DeclConsts CONST ListConst ';' |