forked from pfaure/CrossAssembleur
Changement sorties
This commit is contained in:
parent
85452d879d
commit
e03efe7d14
8 changed files with 112 additions and 20 deletions
21
as.tab.c
21
as.tab.c
|
@ -456,7 +456,7 @@ static const yytype_uint8 yyrline[] =
|
||||||
{
|
{
|
||||||
0, 24, 24, 25, 27, 34, 41, 48, 55, 62,
|
0, 24, 24, 25, 27, 34, 41, 48, 55, 62,
|
||||||
69, 78, 83, 89, 98, 101, 109, 115, 123, 128,
|
69, 78, 83, 89, 98, 101, 109, 115, 123, 128,
|
||||||
135, 141, 146
|
135, 139, 144
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1441,33 +1441,31 @@ yyreduce:
|
||||||
case 20:
|
case 20:
|
||||||
#line 135 "as.y" /* yacc.c:1646 */
|
#line 135 "as.y" /* yacc.c:1646 */
|
||||||
{increment_time();
|
{increment_time();
|
||||||
print();
|
|
||||||
int added_instruction = flush_and_init(file);
|
int added_instruction = flush_and_init(file);
|
||||||
print();
|
|
||||||
add_instruction(CALL, (yyvsp[-1].nombre), (yyvsp[0].nombre), 0);
|
add_instruction(CALL, (yyvsp[-1].nombre), (yyvsp[0].nombre), 0);
|
||||||
new_instruction(added_instruction + 1);}
|
new_instruction(added_instruction + 1);}
|
||||||
#line 1450 "as.tab.c" /* yacc.c:1646 */
|
#line 1448 "as.tab.c" /* yacc.c:1646 */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 21:
|
case 21:
|
||||||
#line 141 "as.y" /* yacc.c:1646 */
|
#line 139 "as.y" /* yacc.c:1646 */
|
||||||
{increment_time();
|
{increment_time();
|
||||||
int added_instruction = flush_and_init(file);
|
int added_instruction = flush_and_init(file);
|
||||||
add_instruction(RET, 0, 0, 0);
|
add_instruction(RET, 0, 0, 0);
|
||||||
new_instruction(added_instruction + 1);}
|
new_instruction(added_instruction + 1);}
|
||||||
#line 1459 "as.tab.c" /* yacc.c:1646 */
|
#line 1457 "as.tab.c" /* yacc.c:1646 */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 22:
|
case 22:
|
||||||
#line 146 "as.y" /* yacc.c:1646 */
|
#line 144 "as.y" /* yacc.c:1646 */
|
||||||
{increment_time();
|
{increment_time();
|
||||||
add_instruction(STOP, (yyvsp[0].nombre), 0, 0);
|
add_instruction(STOP, (yyvsp[0].nombre), 0, 0);
|
||||||
new_instruction(1);}
|
new_instruction(1);}
|
||||||
#line 1467 "as.tab.c" /* yacc.c:1646 */
|
#line 1465 "as.tab.c" /* yacc.c:1646 */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
#line 1471 "as.tab.c" /* yacc.c:1646 */
|
#line 1469 "as.tab.c" /* yacc.c:1646 */
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
/* User semantic actions sometimes alter yychar, and that requires
|
/* User semantic actions sometimes alter yychar, and that requires
|
||||||
|
@ -1695,16 +1693,15 @@ yyreturn:
|
||||||
#endif
|
#endif
|
||||||
return yyresult;
|
return yyresult;
|
||||||
}
|
}
|
||||||
#line 150 "as.y" /* yacc.c:1906 */
|
#line 148 "as.y" /* yacc.c:1906 */
|
||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
file = fopen("output.asm", "w");
|
file = fopen("output.asm", "w");
|
||||||
file2 = fopen("output.bin", "w");
|
file2 = fopen("output.bin", "w");
|
||||||
file = stdout;
|
|
||||||
init();
|
init();
|
||||||
yyparse();
|
yyparse();
|
||||||
write_asm(file);
|
write_asm(file);
|
||||||
write_code_machine(file2);
|
write_code_machine_compact(file2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
BIN
as.tab.o
BIN
as.tab.o
Binary file not shown.
5
as.y
5
as.y
|
@ -133,9 +133,7 @@ Instruction : tPRI tNB {increment_time();
|
||||||
|
|
||||||
|
|
||||||
Instruction : tCALL tNB tNB {increment_time();
|
Instruction : tCALL tNB tNB {increment_time();
|
||||||
print();
|
|
||||||
int added_instruction = flush_and_init(file);
|
int added_instruction = flush_and_init(file);
|
||||||
print();
|
|
||||||
add_instruction(CALL, $2, $3, 0);
|
add_instruction(CALL, $2, $3, 0);
|
||||||
new_instruction(added_instruction + 1);};
|
new_instruction(added_instruction + 1);};
|
||||||
Instruction : tRET {increment_time();
|
Instruction : tRET {increment_time();
|
||||||
|
@ -152,10 +150,9 @@ Instruction : tSTOP tNB {increment_time();
|
||||||
int main(void) {
|
int main(void) {
|
||||||
file = fopen("output.asm", "w");
|
file = fopen("output.asm", "w");
|
||||||
file2 = fopen("output.bin", "w");
|
file2 = fopen("output.bin", "w");
|
||||||
file = stdout;
|
|
||||||
init();
|
init();
|
||||||
yyparse();
|
yyparse();
|
||||||
write_asm(file);
|
write_asm(file);
|
||||||
write_code_machine(file2);
|
write_code_machine_compact(file2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
84
output.asm
84
output.asm
|
@ -0,0 +1,84 @@
|
||||||
|
JMP 48
|
||||||
|
AFC 0 1
|
||||||
|
LOAD 1 0
|
||||||
|
CPY 2 1
|
||||||
|
AFC 3 1
|
||||||
|
MUL 0 3 0
|
||||||
|
ADD 0 2 0
|
||||||
|
LOADI 0 0
|
||||||
|
PRI 0
|
||||||
|
AFC 0 0
|
||||||
|
CPY 2 1
|
||||||
|
AFC 3 1
|
||||||
|
MUL 0 3 0
|
||||||
|
ADD 0 2 0
|
||||||
|
AFC 2 14
|
||||||
|
STOREI 0 2
|
||||||
|
AFC 0 2
|
||||||
|
CPY 1 0
|
||||||
|
STORE 0 1
|
||||||
|
STORE 1 0
|
||||||
|
STORE 2 2
|
||||||
|
STORE 3 3
|
||||||
|
RET
|
||||||
|
AFC 0 0
|
||||||
|
LOAD 1 0
|
||||||
|
CPY 2 1
|
||||||
|
AFC 3 1
|
||||||
|
MUL 0 3 0
|
||||||
|
ADD 0 2 0
|
||||||
|
LOADI 0 0
|
||||||
|
PRI 0
|
||||||
|
AFC 0 1
|
||||||
|
CPY 2 1
|
||||||
|
AFC 3 1
|
||||||
|
MUL 0 3 0
|
||||||
|
ADD 0 2 0
|
||||||
|
AFC 2 10
|
||||||
|
STOREI 0 2
|
||||||
|
CPY 0 1
|
||||||
|
STORE 1 0
|
||||||
|
STORE 2 2
|
||||||
|
STORE 3 3
|
||||||
|
CALL 1 1
|
||||||
|
AFC 0 1
|
||||||
|
CPY 1 0
|
||||||
|
STORE 0 1
|
||||||
|
STORE 1 0
|
||||||
|
RET
|
||||||
|
AFC 0 0
|
||||||
|
AFC 1 0
|
||||||
|
STOREA 3 1
|
||||||
|
AFC 1 1
|
||||||
|
MUL 0 1 0
|
||||||
|
LOAD 2 3
|
||||||
|
ADD 0 2 0
|
||||||
|
AFC 3 1
|
||||||
|
STOREI 0 3
|
||||||
|
AFC 2 1
|
||||||
|
STORE 5 1
|
||||||
|
AFC 1 0
|
||||||
|
STOREA 4 1
|
||||||
|
AFC 1 1
|
||||||
|
MUL 2 1 2
|
||||||
|
STORE 2 0
|
||||||
|
LOAD 0 4
|
||||||
|
ADD 2 0 2
|
||||||
|
AFC 3 12
|
||||||
|
STOREI 2 3
|
||||||
|
STORE 6 1
|
||||||
|
AFC 1 0
|
||||||
|
STOREA 4 1
|
||||||
|
STORE 3 2
|
||||||
|
STORE 5 3
|
||||||
|
CALL 23 4
|
||||||
|
AFC 0 0
|
||||||
|
AFC 1 0
|
||||||
|
STOREA 5 1
|
||||||
|
AFC 1 1
|
||||||
|
MUL 0 1 0
|
||||||
|
LOAD 2 5
|
||||||
|
ADD 0 2 0
|
||||||
|
LOADI 0 0
|
||||||
|
PRI 0
|
||||||
|
STOP 0
|
|
@ -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" & "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" &
|
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101010000000000000000000000001000100000000000000000000000001100000000000000000000000000000010000000000000010000000000101000000010000001010000000000010000000000000000100000000010010000000100000001000000000111000000101000000010000000001001000000010000000000000000010010000000000000000000000001001100010111000001000000000001011000001010000001100000000010110000001100000010000000000111000000100000000010000000001001000000010000000000000000010110000011000000001000000000110100000010000000110000000001001000000110000110000000000000010000001000000000000000100101000000000000001000000000001011000000100000000000000000000100000001000000001000000100100100000001000000010000000001110000001000000000100000000010010000000100000000000000000101100000101000000010000000001001000000100000000100000000011010000000000000011000000000100100000011000000010000000000001000000000000001000000000010100000001000000011000000000001000000000000000010000000001001000000010000000100000000011100000001100000001000000000100100000001000000000000000001001000000000000000000000000101000000000000000000000000000101100000001000000000000000001011000000000000000100000000010000000000100000000000000000100100000000000000010000000010011000000010000000100000000010110000001100000011000000000101100000010000000100000000001011000000010000000000000000010000000000000000001000000000110100000000000000100000000001001000000100000101000000000000010000000000000010000000000001000000000000000110000000001001000000110000000100000000010000000001000000001000000000100100000000000000010000000010001000000000000000000000000011000000000000000000000000000000100000000000000100000000000010000000000000001100000000010010000001100000001000000000100000000010000000010000000001010000000010000000000000000010010000000000000000000000001010000000000000000000000000001011000000110000001100000000010110000001000000010000000000101100000001000000000000000001011000000000000000100000000010000000000100000000000000000100100000000000000100000000001101000000000000001000000000010010000001000001110000000000000100000000000000100000000000010000000000000001100000000010010000001100000001000000000100000000010000000010000000001001000000000000000000000000100010000000000000000000000000110000000000000000000000000000001000000000000001000000000000100000000000000011000000000100100000011000000010000000001000000000100000000100000000010100000000100000000000000000100100000000000000010000000001111001100000000000000000000
|
Binary file not shown.
20
tables.c
20
tables.c
|
@ -109,7 +109,7 @@ void convert_to_binary_on_N(int value, int N, char * buff) {
|
||||||
buff[N] = '\0';
|
buff[N] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_instruction_binary(FILE * file, struct str_instruction instr) {
|
void write_instruction_binary(FILE * file, struct str_instruction instr, char compact) {
|
||||||
char buff1[33];
|
char buff1[33];
|
||||||
char buff2[33];
|
char buff2[33];
|
||||||
char buff3[33];
|
char buff3[33];
|
||||||
|
@ -122,18 +122,32 @@ void write_instruction_binary(FILE * file, struct str_instruction instr) {
|
||||||
}
|
}
|
||||||
convert_to_binary_on_N(instr.param2, NB_BITS, buff3);
|
convert_to_binary_on_N(instr.param2, NB_BITS, buff3);
|
||||||
convert_to_binary_on_N(instr.param3, NB_BITS, buff4);
|
convert_to_binary_on_N(instr.param3, NB_BITS, buff4);
|
||||||
fprintf(file, "\"%s%s%s%s\" & ", buff1, buff2, buff3, buff4);
|
if (compact) {
|
||||||
|
fprintf(file, "%s%s%s%s", buff1, buff2, buff3, buff4);
|
||||||
|
} else {
|
||||||
|
fprintf(file, "\"%s%s%s%s\" & ", buff1, buff2, buff3, buff4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void write_code_machine(FILE * file) {
|
void write_code_machine(FILE * file) {
|
||||||
int i = MEM_INST_SIZE - 1;
|
int i = MEM_INST_SIZE - 1;
|
||||||
while (i>=0) {
|
while (i>=0) {
|
||||||
write_instruction_binary(file, buffer[i]);
|
write_instruction_binary(file, buffer[i], 0);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void write_code_machine_compact(FILE * file) {
|
||||||
|
printf(file, "\"");
|
||||||
|
int i = MEM_INST_SIZE - 1;
|
||||||
|
while (i>=0) {
|
||||||
|
write_instruction_binary(file, buffer[i], 1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
printf(file, "\"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct case_adresse {
|
struct case_adresse {
|
||||||
int adresse;
|
int adresse;
|
||||||
|
|
BIN
tables.o
BIN
tables.o
Binary file not shown.
Loading…
Reference in a new issue