Esempio n. 1
0
 def assembly(self):
     label = lg().new_label('delay')
     dic = {
         'label': label,
         'delay': str(int(self.delay) * 1000),
         'delay_human': self.delay,
     }
     raw = templates.delay_block().format(**dic)
     return bf().nested_block(raw).assembly()
Esempio n. 2
0
 def assembly(self):
     iterations = long_delay_factor(self.delay)
     dic = {
         'delay_human': self.delay,
         'outer_num': str(iterations[0]),
         'inner_num': str(iterations[1] * 1000),
         'offset': str(iterations[2] * 1000 + 1),
         'label_1': lg().new_label('delay'),
         'label_2': lg().new_label('delay'),
         'label_3': lg().new_label('delay'),
         'label_4': lg().new_label('delay'),
     }
     raw = templates.long_delay_block().format(**dic)
     return bf().nested_block(raw).assembly()
Esempio n. 3
0
    def pre_blocks (self):
        sp ().inc ()

        num_loops = Hex (int (self.num_loops))
        self.label = lg ().new_label ('loop')
        dic = {
            'num_loops': num_loops, 
            'num_loops_human': int (num_loops),
            'label': self.label, 
            'sp': sp ().index (),
        }

        raw = templates.loop_pre_block ().format (**dic)
        return bf ().create (raw)
Esempio n. 4
0
    def compile_inside (self):
        if int (self.num_loops) > 12800:
            print 'WARNING: program will not excecute as desired.'
            print 'Too many loops, cannot loop more then 12800 times'

        iterations = factor (self.num_loops, 128)

        dic = {
            'inside_raw': self.inside_raw,
            'outer_num': str (iterations [0]),
            'inner_num': str (iterations [1]),
            'offset': str (iterations [2]),
        }

        raw = templates.long_loop_block ().format (**dic)
        return bf ().create (raw)
Esempio n. 5
0
 def assembly(self):
     dic = {'header': self.header}
     raw = templates.header_block().format(**dic)
     return bf().nested_block(raw).assembly()
Esempio n. 6
0
 def assembly(self):
     if not self.rom_start:
         self.rom_start = '$400'
     dic = {'rom_start': self.rom_start}
     raw = templates.start_block().format(**dic)
     return bf().nested_block(raw).assembly()
Esempio n. 7
0
 def assembly(self):
     raw = templates.interrupt_block()
     return bf().nested_block(raw).assembly()
Esempio n. 8
0
 def assembly(self):
     data = {'on': '#$01', 'off': '#$00'}[self.state]
     dic = {'state': data, 'state_human': self.state}
     raw = templates.LED_block().format(**dic)
     return bf().nested_block(raw).assembly()
Esempio n. 9
0
 def post_blocks (self):
     dic = {'label': self.label}
     raw = templates.loop_inf_post_block ().format (**dic)
     return bf ().create (raw)
Esempio n. 10
0
 def pre_blocks (self):
     self.label = lg ().new_label ('inf')
     dic = {'label': self.label}
     raw = templates.loop_inf_pre_block ().format (**dic)
     return bf ().create (raw)
Esempio n. 11
0
    def post_blocks (self):
        dic = {'sp':sp().index (), 'label':self.label}
        sp ().dec ()

        raw = templates.loop_post_block ().format (**dic)
        return bf ().create (raw)
Esempio n. 12
0
 def compile_inside (self):
     inside = self.pre_blocks ()
     inside += bf ().create (self.inside_raw)
     inside += self.post_blocks ()
     return inside