@@ -91,7 +91,7 @@ def loadVar(reg,var):
91
91
if "|" in type_ or type_ in ["int" , "float" ]:
92
92
code .append ("mov (%" + r + "), %" + reg )
93
93
elif type_ == "char" :
94
- code .append ("movb (%" + r + "), %" + reg )
94
+ code .append ("movb (%" + r + "), %" + reg [ 1 ] + "l" )
95
95
else :
96
96
print ( " class error in load" )
97
97
exit ()
@@ -102,7 +102,7 @@ def loadVar(reg,var):
102
102
code .append ("mov (%ebp , %" + r + ", 1), %" + reg )
103
103
elif type_ == "char" :
104
104
code .append ("neg %" + r )
105
- code .append ("movb (%ebp , %" + r + ", 1), %" + reg )
105
+ code .append ("movb (%ebp , %" + r + ", 1), %" + reg [ 1 ] + "l" )
106
106
else :
107
107
print ( " class error in load" )
108
108
exit ()
@@ -118,7 +118,7 @@ def loadVar(reg,var):
118
118
if "|" in type_ or type_ in ["int" , "float" ]:
119
119
code .append ("mov " + str (- offset ) + "(%ebp), %" + reg )
120
120
elif type_ == "char" :
121
- code .append ("movb " + str (- offset ) + "(%ebp), %" + reg )
121
+ code .append ("movb " + str (- offset ) + "(%ebp), %" + reg [ 1 ] + "l" )
122
122
else :
123
123
print ( " class error in load" )
124
124
exit ()
@@ -128,7 +128,7 @@ def loadVar(reg,var):
128
128
else :
129
129
if var [0 ]== "'" and var [2 ]== "'" and len (var )== 3 :
130
130
# this is char
131
- code .append ("movb $" + str (ord ( var [1 ]))+ " , %" + reg )
131
+ code .append ("movb $" + str (ord ( var [1 ]))+ " , %" + reg [ 1 ] + "l" )
132
132
elif var .isdigit ():
133
133
code .append ("mov $" + var + " , %" + reg )
134
134
else :
@@ -152,7 +152,7 @@ def storeVar(reg,var):
152
152
if "|" in type_ or type_ in ["int" , "float" ]:
153
153
code .append ("mov %" + reg + ", (%" + r + ")" )
154
154
elif type_ == "char" :
155
- code .append ("movb %" + reg + ", (%" + r + ")" )
155
+ code .append ("movb %" + reg [ 1 ] + "l" + ", (%" + r + ")" )
156
156
else :
157
157
print ( " class error in store" )
158
158
exit ()
@@ -163,7 +163,7 @@ def storeVar(reg,var):
163
163
code .append ("mov %" + reg + ", (%ebp , %" + r + ", 1)" )
164
164
elif type_ == "char" :
165
165
code .append ("neg %" + r )
166
- code .append ("movb %" + reg + ", (%ebp , %" + r + ", 1)" )
166
+ code .append ("movb %" + reg [ 1 ] + "l" + ", (%ebp , %" + r + ", 1)" )
167
167
else :
168
168
print ( " class error in store" )
169
169
exit ()
@@ -179,7 +179,7 @@ def storeVar(reg,var):
179
179
if "|" in type_ or type_ in ["int" , "float" ]:
180
180
code .append ("mov %" + reg + " , " + str (- offset ) + "(%ebp)" )
181
181
elif type_ == "char" :
182
- code .append ("movb %" + reg + " , " + str (- offset ) + "(%ebp)" )
182
+ code .append ("movb %" + reg [ 1 ] + "l" + " , " + str (- offset ) + "(%ebp)" )
183
183
else :
184
184
print ( " class error in store" )
185
185
exit ()
@@ -428,7 +428,7 @@ def op_assign(self,instr):
428
428
info = checkVar (out , "all" )["var" ] if out .split ('@' )[0 ]== "tmp" else checkVar (out .split ('@' )[0 ], int (out .split ('@' )[1 ]))
429
429
type_ = info ["type" ]
430
430
if type_ == "char" :
431
- code .append ("movb $" + str (ord (inp [1 ])) + ",%eax" )
431
+ code .append ("mov $" + str (ord (inp [1 ])) + ",%eax" )
432
432
storeVar ("eax" , out )
433
433
else :
434
434
code .append ("mov $" + inp + ", %eax" )
0 commit comments