Browse Source

CrossAssembler OKKKKKKKKKKKKKK

Paul Faure 2 years ago
parent
commit
85452d879d
11 changed files with 309 additions and 367 deletions
  1. 257
    356
      as.tab.c
  2. 6
    9
      as.tab.h
  3. BIN
      as.tab.o
  4. 1
    0
      as.y
  5. BIN
      lex.yy.o
  6. 1
    1
      output.bin
  7. BIN
      rondoudou_cross_assembleur
  8. 3
    0
      tables.c
  9. 1
    0
      tables.h
  10. BIN
      tables.o
  11. 40
    1
      toto.asm

+ 257
- 356
as.tab.c
File diff suppressed because it is too large
View File


+ 6
- 9
as.tab.h View File

@@ -1,9 +1,8 @@
1
-/* A Bison parser, made by GNU Bison 3.5.1.  */
1
+/* A Bison parser, made by GNU Bison 3.0.4.  */
2 2
 
3 3
 /* Bison interface for Yacc-like parsers in C
4 4
 
5
-   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
6
-   Inc.
5
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
7 6
 
8 7
    This program is free software: you can redistribute it and/or modify
9 8
    it under the terms of the GNU General Public License as published by
@@ -31,9 +30,6 @@
31 30
    This special exception was added by the Free Software Foundation in
32 31
    version 2.2 of Bison.  */
33 32
 
34
-/* Undocumented macros, especially those whose name start with YY_,
35
-   are private implementation details.  Do not rely on them.  */
36
-
37 33
 #ifndef YY_YY_AS_TAB_H_INCLUDED
38 34
 # define YY_YY_AS_TAB_H_INCLUDED
39 35
 /* Debug traces.  */
@@ -74,15 +70,16 @@ extern int yydebug;
74 70
 
75 71
 /* Value type.  */
76 72
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
73
+
77 74
 union YYSTYPE
78 75
 {
79
-#line 1 "as.y"
76
+#line 1 "as.y" /* yacc.c:1909  */
80 77
 
81 78
 	int nombre;
82 79
 
83
-#line 84 "as.tab.h"
84
-
80
+#line 81 "as.tab.h" /* yacc.c:1909  */
85 81
 };
82
+
86 83
 typedef union YYSTYPE YYSTYPE;
87 84
 # define YYSTYPE_IS_TRIVIAL 1
88 85
 # define YYSTYPE_IS_DECLARED 1

BIN
as.tab.o View File


+ 1
- 0
as.y View File

@@ -91,6 +91,7 @@ Instruction : tAFCA tNB tNB     {increment_time();
91 91
 																int reg_aux = get_reg_write(-1, &added_instruction);
92 92
 																add_instruction(AFC, reg_aux, $3, 0);
93 93
 																add_instruction(STOREA, $2, reg_aux, 0);
94
+																unlink($2);
94 95
 																new_instruction(added_instruction + 2);};
95 96
 
96 97
 

BIN
lex.yy.o View File


+ 1
- 1
output.bin View File

@@ -1 +1 @@
1
-"00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "10101000000000000000000000000" & "10001000000110000000000000000" & "01101000000110000001100000000" & "00001000000110000000000000011" & "00010000000110000000100000011" & "01001000000010000000100000000" & "01110000001010000000100000000" & "01001000000010000000000000000" & "01011000001100000000100000000" & "01001000000110000000000000000" & "01100000000100000000000000000" & "01001000000000000110000000000" & "01011000000100000000000000000" & "00001000000100000001100000010" & "00010000000100000000100000010" & "01001000000010000000100000000" & "01110000001000000000100000000" & "01001000000010000000000000000" & "01011000001010000000100000000" & "01001000000100000000100000000" & "01100000000000000001100000000" & "01001000000110000000100000000" & "00001000000000000001000000000" & "01010000000100000001100000000" & "00010000000000000000100000000" & "01001000000010000000100000000" & "01110000000110000000100000000" & "01001000000010000000000000000" & "01001000000000000000000000000" & "01111000000010000000000000000" & 
1
+"00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "00000000000000000000000000000" & "10101000000000000000000000000" & "10001000000000000000000000000" & "01100000000000000000000000000" & "00001000000000000001000000000" & "01010000000100000010100000000" & "00010000000000000000100000000" & "01001000000010000000100000000" & "01110000001010000000100000000" & "01001000000010000000000000000" & "01001000000000000000000000000" & "10011000101110000010000000000" & "01011000001010000001100000000" & "01011000000110000001000000000" & "01110000001000000000100000000" & "01001000000010000000000000000" & "01011000001100000000100000000" & "01101000000100000001100000000" & "01001000000110000110000000000" & "00001000000100000000000000010" & "01010000000000000010000000000" & "01011000000100000000000000000" & "00010000000100000000100000010" & "01001000000010000000100000000" & "01110000001000000000100000000" & "01001000000010000000000000000" & "01011000001010000000100000000" & "01001000000100000000100000000" & "01101000000000000001100000000" & "01001000000110000000100000000" & "00001000000000000001000000000" & "01010000000100000001100000000" & "00010000000000000000100000000" & "01001000000010000000100000000" & "01110000000110000000100000000" & "01001000000010000000000000000" & "01001000000000000000000000000" & "10100000000000000000000000000" & "01011000000010000000000000000" & "01011000000000000000100000000" & "01000000000010000000000000000" & "01001000000000000000100000000" & "10011000000010000000100000000" & "01011000000110000001100000000" & "01011000000100000001000000000" & "01011000000010000000000000000" & "01000000000000000000100000000" & "01101000000000000001000000000" & "01001000000100000101000000000" & "00001000000000000001000000000" & "00010000000000000001100000000" & "01001000000110000000100000000" & "01000000000100000000100000000" & "01001000000000000000100000000" & "10001000000000000000000000000" & "01100000000000000000000000000" & "00001000000000000001000000000" & "00010000000000000001100000000" & "01001000000110000000100000000" & "01000000000100000000100000000" & "01010000000010000000000000000" & "01001000000000000000000000000" & "10100000000000000000000000000" & "01011000000110000001100000000" & "01011000000100000001000000000" & "01011000000010000000000000000" & "01011000000000000000100000000" & "01000000000010000000000000000" & "01001000000000000001000000000" & "01101000000000000001000000000" & "01001000000100000111000000000" & "00001000000000000001000000000" & "00010000000000000001100000000" & "01001000000110000000100000000" & "01000000000100000000100000000" & "01001000000000000000000000000" & "10001000000000000000000000000" & "01100000000000000000000000000" & "00001000000000000001000000000" & "00010000000000000001100000000" & "01001000000110000000100000000" & "01000000000100000000100000000" & "01010000000010000000000000000" & "01001000000000000000100000000" & "01111001100000000000000000000" & 

BIN
rondoudou_cross_assembleur View File


+ 3
- 0
tables.c View File

@@ -282,6 +282,9 @@ int get_reg_read(int adresse, int * added_instruction) {
282 282
 	}
283 283
 }
284 284
 
285
+void unlink(int adresse) {
286
+	set_registre(adresse, -1);
287
+}
285 288
 
286 289
 int flush_and_init() {
287 290
 	int i;

+ 1
- 0
tables.h View File

@@ -25,6 +25,7 @@ void print();
25 25
 void increment_time();
26 26
 int get_reg_read(int adresse, int * added_instruction);
27 27
 int get_reg_write(int adresse, int * added_instruction);
28
+void unlink(int adresse);
28 29
 int flush_and_init();
29 30
 void new_instruction(int nb_inst);
30 31
 void write_asm(FILE * file);

BIN
tables.o View File


+ 40
- 1
toto.asm View File

@@ -1,4 +1,40 @@
1
-JMP 1
1
+JMP 37
2
+AFC 1 1
3
+COP 2 0
4
+AFC 3 1
5
+MUL 1 3 1
6
+ADD 1 2 1
7
+READ 1 1
8
+PRI 1
9
+AFC 1 0
10
+COP 2 0
11
+AFC 3 1
12
+MUL 1 3 1
13
+ADD 1 2 1
14
+AFC 2 14
15
+WR 1 2
16
+AFC 1 2
17
+COP 0 1
18
+RET
19
+AFC 1 0
20
+COP 2 0
21
+AFC 3 1
22
+MUL 1 3 1
23
+ADD 1 2 1
24
+READ 1 1
25
+PRI 1
26
+AFC 1 1
27
+COP 2 0
28
+AFC 3 1
29
+MUL 1 3 1
30
+ADD 1 2 1
31
+AFC 2 10
32
+WR 1 2
33
+COP 1 0
34
+CALL 1 1
35
+AFC 1 1
36
+COP 0 1
37
+RET
2 38
 AFC 2 0
3 39
 AFCA 3 0
4 40
 AFC 5 1
@@ -13,6 +49,8 @@ MUL 3 6 3
13 49
 ADD 3 4 3
14 50
 AFC 5 12
15 51
 WR 3 5
52
+AFCA 4 0
53
+CALL 18 4
16 54
 AFC 4 0
17 55
 AFCA 5 0
18 56
 AFC 6 1
@@ -21,3 +59,4 @@ ADD 4 5 4
21 59
 READ 4 4
22 60
 PRI 4
23 61
 STOP 0
62
+

Loading…
Cancel
Save