Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compiler-construction
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
User expired
compiler-construction
Commits
b8cd191b
Commit
b8cd191b
authored
5 years ago
by
FlorianKrull
Browse files
Options
Downloads
Patches
Plain Diff
Added array, commented offset temporary printf
parent
148859d4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/assembly_gen.c
+23
-1
23 additions, 1 deletion
src/assembly_gen.c
with
23 additions
and
1 deletion
src/assembly_gen.c
+
23
−
1
View file @
b8cd191b
...
...
@@ -13,7 +13,7 @@ struct mcc_assembly_offset *find_var(char *temp, struct mcc_asm_gen_container *a
struct
mcc_assembly_offset
*
a_offset
=
NULL
;
for
(
int
i
=
0
;
i
<
asm_container
->
variable_offsets
->
size
;
i
++
)
{
struct
mcc_assembly_offset
*
ao
=
(
struct
mcc_assembly_offset
*
)
asm_container
->
variable_offsets
->
arr
[
i
];
printf
(
"%s %s
\n
"
,
temp
,
ao
->
temporary
);
//
printf("%s %s\n", temp, ao -> temporary);
if
(
strcmp
(
ao
->
temporary
,
temp
)
==
0
)
{
a_offset
=
ao
;
break
;
...
...
@@ -86,6 +86,15 @@ void asm_gen_assignment_float(FILE *out, struct mcc_tac_entry *te, struct mcc_as
fprintf
(
out
,
"
\t
fstps %d(%%ebp)
\n
"
,
mcc_assembly_get_current_offset
(
asm_container
));
}
void
asm_gen_param
(
FILE
*
out
,
struct
mcc_tac_entry
*
te
,
struct
mcc_asm_gen_container
*
asm_container
)
{
fprintf
(
out
,
"
\t
pushl
\t
%d(%%ebp)
\n
"
,
mcc_assembly_get_current_offset
(
asm_container
));
}
void
asm_gen_param_array
(
FILE
*
out
,
struct
mcc_tac_entry
*
te
,
struct
mcc_asm_gen_container
*
asm_container
)
{
fprintf
(
out
,
"
\t
leal
\t
%d(%%ebp), %%eax
\n
"
,
mcc_assembly_get_current_offset
(
asm_container
));
fprintf
(
out
,
"
\t
pushl
\t
%%eax
\n
"
);
}
void
asm_gen_binary_int_op
(
FILE
*
out
,
struct
mcc_tac_entry
*
te
,
struct
mcc_asm_gen_container
*
asm_container
)
{
fprintf
(
out
,
"
\t
movl
\t
%d(%%ebp), %%eax
\n
"
,
mcc_assembly_get_current_offset
(
asm_container
));
...
...
@@ -187,6 +196,19 @@ void mcc_asm_gen(FILE *out, struct mcc_tac *tac, struct mcc_asm_gen_container *a
case
MCC_TAC_DIV_FLOAT
:
asm_gen_binary_float_op
(
out
,
entry
,
asm_container
);
break
;
// push
case
MCC_TAC_PARAM_BOOL
:
case
MCC_TAC_PARAM_INT
:
case
MCC_TAC_PARAM_FLOAT
:
case
MCC_TAC_PARAM_STRING
:
asm_gen_param
(
out
,
entry
,
asm_container
);
break
;
case
MCC_TAC_PARAM_BOOL_ARR
:
case
MCC_TAC_PARAM_INT_ARR
:
case
MCC_TAC_PARAM_FLOAT_ARR
:
case
MCC_TAC_PARAM_STRING_ARR
:
asm_gen_param_array
(
out
,
entry
,
asm_container
);
break
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment