本文整理汇总了Python中utility.Bits.getNthBit方法的典型用法代码示例。如果您正苦于以下问题:Python Bits.getNthBit方法的具体用法?Python Bits.getNthBit怎么用?Python Bits.getNthBit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utility.Bits
的用法示例。
在下文中一共展示了Bits.getNthBit方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_Hl_rr_c
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def add_Hl_rr_c(cpu, opcode, logger):
regInd = (opcode >> 4) & 3
val = cpu.Reg16(regInd)
old = cpu.HL
cpu.HL = cpu.HL + val + (1 if cpu.CFlag else 0)
cpu.SFlag = Bits.signFlag(cpu.HL, bits=16)
cpu.ZFlag = Bits.isZero(cpu.HL)
cpu.HFlag = Bits.halfCarrySub16(old, cpu.HL)
cpu.PVFlag = Bits.overflow(old, cpu.HL, bits=16)
cpu.NFlag = Bits.reset()
cpu.CFlag = Bits.set() if (Bits.getNthBit(old, 15) == 1 and
Bits.getNthBit(cpu.HL, 15) == 0) else Bits.reset()
cpu.m_cycles, cpu.t_states = 4, 15
logger.info("ADC HL, {}".format(IndexToReg.translate16Bit(regInd)))
示例2: rlca
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def rlca(cpu, opcode, logger):
cflag = Bits.getNthBit(cpu.A, 7)
cpu.A = Bits.setNthBit(cpu.A << 1, 0, cflag)
cpu.CFlag = Bits.set() if cflag != 0 else Bits.reset()
cpu.m_cycles, cpu.t_states = 1, 4
logger.info("RLCA")
示例3: rra
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def rra(cpu, opcode, logger):
cflag = Bits.getNthBit(cpu.A, 0)
cpu.A = Bits.setNthBit((cpu.A >> 1), 7, cpu.CFlag)
cpu.CFlag = Bits.set() if cflag == 1 else Bits.reset()
cpu.HFlag = Bits.reset()
cpu.NFlag = Bits.reset()
cpu.m_cycles, cpu.t_states = 1, 4
logger.info("RRA")
示例4: srl_r
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def srl_r(cpu, opcode, logger):
reg_idx = (opcode & 7)
old_val = cpu.regs[reg_idx]
cpu.regs[reg_idx] = (old_val >> 1)
last_bit = Bits.getNthBit(old_val, 0)
cpu.CFlag = Bits.set() if last_bit == 1 else Bits.reset()
cpu.NFlag = Bits.reset()
cpu.HFlag = Bits.reset()
cpu.ZFlag = Bits.isZero(cpu.regs[reg_idx])
cpu.PVFlag = Bits.isEvenParity(cpu.regs[reg_idx])
cpu.SFlag = Bits.reset()
cpu.m_cycles, cpu.t_states = 2, 8
logger.info("SRL {}".format(IndexToReg.translate8Bit(reg_idx)))
示例5: lra
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def lra(cpu, opcode, logger):
cflag = Bits.getNthBit(cpu.A, 7)
cpu.A = Bits.setNthBit((cpu.A << 1), 0, cpu.CFlag)
cpu.CFlag = Bits.set() if cflag == 1 else Bits.reset()
cpu.m_cycles, cpu.t_states = 1, 4
logger.info("LRA")
示例6: CFlag
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def CFlag(self):
return Bits.getNthBit(self.F, CF) == 1
示例7: PVFlag
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def PVFlag(self):
return Bits.getNthBit(self.F, PVF) == 1
示例8: ZFlag
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def ZFlag(self):
return Bits.getNthBit(self.F, ZF) == 1
示例9: SFlag
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def SFlag(self):
return Bits.getNthBit(self.F, SF) == 1
示例10: HFlag
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def HFlag(self):
return Bits.getNthBit(self.F, HF) == 1
示例11: NFlag
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def NFlag(self):
return Bits.getNthBit(self.F, NF) == 1
示例12: test_bits_getNthBit_returns_1_for_N_equals_2_and_value_14
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def test_bits_getNthBit_returns_1_for_N_equals_2_and_value_14(self):
self.assertEquals(1, Bits.getNthBit(14, 2))
示例13: state
# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import getNthBit [as 别名]
def state(self, flag, flag_bit, flag_name):
state = Bits.getNthBit(flag, flag_bit)
return flag_name if state != 0 else flag_name.lower()