Fix several bugs

This commit is contained in:
Augusto Gunsch 2020-11-01 19:39:27 -03:00
parent ae2e7f7362
commit 3fdf4c1281
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
2 changed files with 11 additions and 24 deletions

View File

@ -63,17 +63,6 @@ char* tpop[TPOPN] = {
#define TPOPSTATN 7 #define TPOPSTATN 7
char* tpopstat[TPOPSTATN] = { char* tpopstat[TPOPSTATN] = {
"",
"@SP",
"M=M-1",
"A=M+1",
"D=M",
"",
""
};
#define TPOPTEMPN 7
char* tpoptemp[TPOPTEMPN] = {
"", "",
"@SP", "@SP",
"M=M-1", "M=M-1",
@ -83,16 +72,11 @@ char* tpoptemp[TPOPTEMPN] = {
"" ""
}; };
#define TPOPPOINTERN 7 #define TPOPTEMPN TPOPSTATN
char* tpoppointer[TPOPPOINTERN] = { char** tpoptemp = tpopstat;
"",
"@SP", #define TPOPPOINTERN TPOPSTATN
"M=M-1", char** tpoppointer = tpopstat;
"A=M",
"D=M",
"",
"M=D"
};
#define TARITHN 7 #define TARITHN 7
char* tarith[TARITHN] = { char* tarith[TARITHN] = {
@ -131,7 +115,7 @@ char* tcomp[TCOMPN] = {
"D=M", "D=M",
"A=A-1", "A=A-1",
"D=D-M", "D=D-M",
"M=1", "M=-1",
"", "",
"", "",
"@SP", "@SP",

View File

@ -297,6 +297,9 @@ void poppointer(struct Translator* t, struct line* ln, int indlen) {
// @THIS/@THAT // @THIS/@THAT
tpoppointer[TPOPPOINTERN-2] = mkpointerind(t, ln, indlen); tpoppointer[TPOPPOINTERN-2] = mkpointerind(t, ln, indlen);
// M=D
tpoppointer[TPOPPOINTERN-1] = heapstr(t, "M=D");
addasmlns(t, ln, tpoppointer, TPOPPOINTERN); addasmlns(t, ln, tpoppointer, TPOPPOINTERN);
} }
@ -380,9 +383,9 @@ void switchop(struct Translator* t, struct line* ln) {
else if(!strcmp(op, "eq")) else if(!strcmp(op, "eq"))
comp(t, ln, "EQ"); comp(t, ln, "EQ");
else if(!strcmp(op, "gt")) else if(!strcmp(op, "gt"))
comp(t, ln, "GT");
else if(!strcmp(op, "lt"))
comp(t, ln, "LT"); comp(t, ln, "LT");
else if(!strcmp(op, "lt"))
comp(t, ln, "GT");
else if(!strcmp(op, "and")) else if(!strcmp(op, "and"))
arith(t, ln, "M=M&D"); arith(t, ln, "M=M&D");
else if(!strcmp(op, "or")) else if(!strcmp(op, "or"))