Fix several bugs
This commit is contained in:
parent
ae2e7f7362
commit
3fdf4c1281
28
templates.h
28
templates.h
|
@ -63,17 +63,6 @@ char* tpop[TPOPN] = {
|
|||
|
||||
#define TPOPSTATN 7
|
||||
char* tpopstat[TPOPSTATN] = {
|
||||
"",
|
||||
"@SP",
|
||||
"M=M-1",
|
||||
"A=M+1",
|
||||
"D=M",
|
||||
"",
|
||||
""
|
||||
};
|
||||
|
||||
#define TPOPTEMPN 7
|
||||
char* tpoptemp[TPOPTEMPN] = {
|
||||
"",
|
||||
"@SP",
|
||||
"M=M-1",
|
||||
|
@ -83,16 +72,11 @@ char* tpoptemp[TPOPTEMPN] = {
|
|||
""
|
||||
};
|
||||
|
||||
#define TPOPPOINTERN 7
|
||||
char* tpoppointer[TPOPPOINTERN] = {
|
||||
"",
|
||||
"@SP",
|
||||
"M=M-1",
|
||||
"A=M",
|
||||
"D=M",
|
||||
"",
|
||||
"M=D"
|
||||
};
|
||||
#define TPOPTEMPN TPOPSTATN
|
||||
char** tpoptemp = tpopstat;
|
||||
|
||||
#define TPOPPOINTERN TPOPSTATN
|
||||
char** tpoppointer = tpopstat;
|
||||
|
||||
#define TARITHN 7
|
||||
char* tarith[TARITHN] = {
|
||||
|
@ -131,7 +115,7 @@ char* tcomp[TCOMPN] = {
|
|||
"D=M",
|
||||
"A=A-1",
|
||||
"D=D-M",
|
||||
"M=1",
|
||||
"M=-1",
|
||||
"",
|
||||
"",
|
||||
"@SP",
|
||||
|
|
|
@ -297,6 +297,9 @@ void poppointer(struct Translator* t, struct line* ln, int indlen) {
|
|||
// @THIS/@THAT
|
||||
tpoppointer[TPOPPOINTERN-2] = mkpointerind(t, ln, indlen);
|
||||
|
||||
// M=D
|
||||
tpoppointer[TPOPPOINTERN-1] = heapstr(t, "M=D");
|
||||
|
||||
addasmlns(t, ln, tpoppointer, TPOPPOINTERN);
|
||||
}
|
||||
|
||||
|
@ -380,9 +383,9 @@ void switchop(struct Translator* t, struct line* ln) {
|
|||
else if(!strcmp(op, "eq"))
|
||||
comp(t, ln, "EQ");
|
||||
else if(!strcmp(op, "gt"))
|
||||
comp(t, ln, "GT");
|
||||
else if(!strcmp(op, "lt"))
|
||||
comp(t, ln, "LT");
|
||||
else if(!strcmp(op, "lt"))
|
||||
comp(t, ln, "GT");
|
||||
else if(!strcmp(op, "and"))
|
||||
arith(t, ln, "M=M&D");
|
||||
else if(!strcmp(op, "or"))
|
||||
|
|
Loading…
Reference in New Issue