Пример #1
0
 def _load_word(self, array, reg, word):
     """Load an immediate value into a register w/o using load_word(); instead
    append the instruction objects to an array.
    Used when synthesizing the prologue/epilogue."""
     array.append(ppc.addi(reg, 0, word & 0xFFFF, ignore_active=True))
     if (word & 0xFFFF) != word:
         array.append(
             ppc.addis(reg,
                       reg, ((word + 32768) >> 16) & 0xFFFF,
                       ignore_active=True))
     return
Пример #2
0
    def _set_literal_value(self, value):
        # Put the lower 16 bits into r-temp
        self.code.add(ppc.addi(self.reg, 0, value & 0xFFFF))

        # Addis r-temp with the upper 16 bits (shifted add immediate) and
        # put the result in r-target
        if (value & 0x7FFF) != value:
            self.code.add(
                ppc.addis(self.reg, self.reg, ((value + 32768) >> 16)))

        return
Пример #3
0
def load_word(code, r_target, word):
    """
  Generate the instruction sequence to load a word into r-target.
  
  This can be used for any value greater than 2^16.
  """
    # Put the lower 16 bits into r-temp
    start = code.add(ppc.addi(r_target, 0, word & 0xFFFF))

    # Addis r-temp with the upper 16 bits (shifted add immediate) and
    # put the result in r-target
    if (word & 0xFFFF) != word:
        code.add(ppc.addis(r_target, r_target,
                           ((word + 32768) >> 16) & 0xFFFF))
    return start
Пример #4
0
    def _load_word(self, array, reg, word):
        """Load an immediate value into a register w/o using load_word(); instead
       append the instruction objects to an array.
       Used when synthesizing the prologue/epilogue."""
        array.append(ppc.addi(reg, 0, word & 0xFFFF, ignore_active=True))

        uw = (word >> 16) & 0xFFFF
        msb = word & 0x8000

        if msb != 0:
            # lower 16-bit MSB is set, upper 16 bits are 1, adjust uw
            # If all upper 16 bits are 1, that is the value -1, so add 1 back in.
            uw = (uw + 1) & 0xFFFF

        if uw != 0:
            array.append(ppc.addis(reg, reg, uw, ignore_active=True))
        return
Пример #5
0
    def _load_word(self, array, reg, word):
        """Load an immediate value into a register w/o using load_word(); instead
       append the instruction objects to an array.
       Used when synthesizing the prologue/epilogue."""
        array.append(ppc.addi(reg, 0, word & 0xFFFF, ignore_active=True))

        uw = (word >> 16) & 0xFFFF
        msb = word & 0x8000

        if msb != 0:
            # lower 16-bit MSB is set, upper 16 bits are 1, adjust uw
            # If all upper 16 bits are 1, that is the value -1, so add 1 back in.
            uw = (uw + 1) & 0xFFFF

        if uw != 0:
            array.append(ppc.addis(reg, reg, uw, ignore_active=True))
        return
Пример #6
0
def load_word(code, r_target, word):
    """
  Generate the instruction sequence to load a word into r-target.
  
  This can be used for any value greater than 2^16.
  """

    # Put the lower 16 bits into r_target
    start = code.add(ppc.addi(r_target, 0, word & 0xFFFF))

    uw = (word >> 16) & 0xFFFF
    msb = word & 0x8000

    if msb != 0:
        # lower 16-bit MSB is set, upper 16 bits are 1, adjust uw
        # If all upper 16 bits are 1, that is the value -1, so add 1 back in.
        uw = (uw + 1) & 0xFFFF

    # Only issue addis if the value added (uw) is not zero.
    if uw != 0:
        code.add(ppc.addis(r_target, r_target, uw))

    return start
Пример #7
0
def load_word(code, r_target, word):
  """
  Generate the instruction sequence to load a word into r-target.
  
  This can be used for any value greater than 2^16.
  """

  # Put the lower 16 bits into r_target
  start = code.add(ppc.addi(r_target, 0, word & 0xFFFF))

  uw = (word >> 16) & 0xFFFF
  msb = word & 0x8000

  if msb != 0:
    # lower 16-bit MSB is set, upper 16 bits are 1, adjust uw
    # If all upper 16 bits are 1, that is the value -1, so add 1 back in.
    uw = (uw + 1) & 0xFFFF

  # Only issue addis if the value added (uw) is not zero.
  if uw != 0:
    code.add(ppc.addis(r_target, r_target, uw))

  return start