Example #1
0
 def compile(self):
     emit.comment("system code")
     emit.RM("LDC", SP, 0, 0)
     emit.RM("LDA", 1, 2, PC)
     emit.RM("ST", 1, 1+_table.nargs("main"), SP)
     self.mainLabel.produce(
         lambda origin, target:
             emit.RMAbs("LDA", PC, target, "jump to main", origin)
     )
     emit.skip()
     
     emit.RM("LD", 1, 0, SP)
     emit.RO("OUT", 1, 0,0)
     emit.RO("HALT", 0,0,0, "done.")
     
     emit.comment("print function")
     self.printLabel.compile()
     
     emit.RM("LD", 1, 1, SP)
     emit.RM("LDA", 2, 2, SP)
     
     emit.RM("LD",  3, 0, 2)
     emit.RO("OUT", 3, 0, 0)
     emit.RM("LDA", 2, 1, 2)
     emit.RM("LDA", 1, -1, 1)
     emit.RM("JNE", 1, -5, 7)
     
     emit.RM("LD", 1, 1, SP)
     emit.RO("ADD", 1, 1, SP)
     emit.RM("LD", 7,  2, 1)
     
     emit.comment("program code")
Example #2
0
 def compile(self):
     emit.comment(repr(self))
Example #3
0
 def compile(self):
     emit.comment(repr(self))
     self.location = emit.location()
     for fn, origin in self.fns:
         fn(origin, self.location)
     del self.fns
Example #4
0
 def compile(self):
     emit.comment(repr(self))
     global _stack, _registers
     _stack = stack(self.nargs)
     _stack.writeProgState()
     _registers = registers()