Exemple #1
0
 def Print(self, i):
     code = self.emit(x.pushl, i.a)
     code += [
         x.pushl('$printf_msg'),
         x.call("printf"),
         x.addl(x.cint(8), x.esp),
     ]
     return code
Exemple #2
0
 def Return(self, i):
     code = list()
     #if len(self.code) >= 90 and len(self.code) < 110:
         #code = [
             #(vm.IMM,  3, len(self.code), 'DEBUG'),
             #(vm.PRNT, 3, 0, 'DEBUG'),
             #(vm.PRNT, 2, 0, 'DEBUG'),
             #(vm.EXIT, 0, 0, 'DEBUG'),
         #]
     code += [
         x.addl(x.cint(4), x.esp),
         x.jmp(x.mem(x.esp, -4, True)),
         #x.ret(),
     ]
     return code
Exemple #3
0
 def Return(self, i):
     """Generate code to return from the current function"""
     return [x.addl(x.cint(4), x.esp), x.jmp(x.mem(x.esp, -4, True))]