示例#1
0
  def end(self, branch = True):
    if self.mode == CTR and branch:
        self.code.add(ppc.bdnz(self.start_label))

    elif self.mode == DEC:
      # branch if r_count is not zero (CR)
      #   Note that this relies on someone (e.g. cleanup()) setting the
      #   condition register properly.
      if branch:
        self.code.add(ppc.bgt(self.start_label))

      # Reset the counter in case this is a nested loop
      util.load_word(self.code, self.r_count, self.get_count())

    elif self.mode == INC:
      # branch if r_current < r_stop
      if branch:
        self.code.add(ppc.cmpw(0, self.r_count, self.r_stop))
        #self.code.add(ppc.cmp_(0, 2, self.r_count, self.r_stop))
        self.code.add(ppc.blt(self.start_label))
      
      # Reset the the current value in case this is a nested loop
      util.load_word(self.code, self.r_count, self.get_start())

    if self.r_count is not None:
      self.code.prgm.release_register(self.r_count)
      self.r_count = None
      
    if self.r_stop is not None and not self.external_stop:
      self.code.prgm.release_register(self.r_stop)      
      self.r_count = None
    return
示例#2
0
r = proc.execute(prgm, mode='int', debug=True)
print "int result:",r
assert(r == -1)


code.reset()

ppc.addi(prgm.gp_return, 0, 16)
ppc.mtctr(prgm.gp_return)
ppc.addi(prgm.gp_return, 0, 0)

lbl_loop = prgm.get_label("LOOP")
code.add(lbl_loop)
ppc.addi(prgm.gp_return, prgm.gp_return, 2)
ppc.bdnz(lbl_loop)

#prgm.print_code(hex = True)
r = proc.execute(prgm, mode='int', debug=True)
print "int result:",r
assert(r == 32)

#sys.exit(0)

# ------------------------------------------------------------
# Variables/Exprsesions
# ------------------------------------------------------------

# Without active code
ppc.set_active_code(None)
code.reset()
示例#3
0
文件: basics.py 项目: tmaone/efi
load_word(code, code.gp_return, 0xFFFFFFFF)

r = proc.execute(code, mode='int', debug=True)
print "int result:", r
assert (r == -1)

code.reset()

ppc.addi(code.gp_return, 0, 16)
ppc.mtctr(code.gp_return)
ppc.addi(code.gp_return, 0, 0)

lbl_loop = code.get_label("LOOP")
code.add(lbl_loop)
ppc.addi(code.gp_return, code.gp_return, 2)
ppc.bdnz(lbl_loop)

code.print_code(hex=True)
r = proc.execute(code, mode='int', debug=True)
print "int result:", r
assert (r == 32)

sys.exit(0)

# ------------------------------------------------------------
# Variables/Exprsesions
# ------------------------------------------------------------

# Without active code
ppc.set_active_code(None)
code.reset()