• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utility.Bits类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utility.Bits的典型用法代码示例。如果您正苦于以下问题:Python Bits类的具体用法?Python Bits怎么用?Python Bits使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Bits类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: rlca

    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")
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:7,代码来源:opcodes.py


示例2: test_jr_z_does_not_change_the_z_flag

 def test_jr_z_does_not_change_the_z_flag(self):
     cpu = CPU(ROM('\x28\x00\x28\x00'))
     cpu.ZFlag = Bits.reset()
     cpu.readOp()
     self.assertFalse(cpu.ZFlag)
     cpu.ZFlag = Bits.set()
     cpu.readOp()
     self.assertTrue(cpu.ZFlag)
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:8,代码来源:tests_jrz.py


示例3: cpl

 def cpl(cpu, opcode, logger):
     old = cpu.A
     new = ~old
     cpu.A = new
     cpu.HFlag = Bits.set()
     cpu.NFlag = Bits.set()
     cpu.m_cycles, cpu.t_states = 1, 4
     logger.info("CPL")
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:8,代码来源:opcodes.py


示例4: _checkInterrupts

 def _checkInterrupts(self):
     if self.iff1:
         self.halted = Bits.reset()
         self.iff1 = Bits.reset()
         self.iff2 = Bits.reset()
         self.ram[--self.SP] = Bits.limitTo8Bits(self.pc)
         self.ram[--self.SP] = self.pc >> 8
         self.R += 1
         if self.im == 0 or self.im == 1:
             self.PC = 0x0038
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:10,代码来源:cpu.py


示例5: dec_at_hl

 def dec_at_hl(cpu, opcode, logger):
     old_val = cpu.ram[cpu.HL]
     new_val = old_val - 1
     cpu.ram[cpu.HL] = new_val
     cpu.ZFlag = Bits.isZero(new_val)
     cpu.SFlag = Bits.isNegative(new_val)
     cpu.NFlag = Bits.set()
     cpu.PVFlag = Bits.halfCarrySub(old_val, new_val)
     cpu.m_cycles, cpu.t_states = 3, 11
     logger.info("DEC (HL)")
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:10,代码来源:opcodes.py


示例6: _and

	def _and(cpu, opcode, logger):
		logger.info("AND A")
		regInd = opcode & 7
		cpu.A = cpu.A & cpu.regs[regInd]
		cpu.flags[HF] = True
		cpu.flags[CF] = False
		cpu.flags[NF] = False
		cpu.flags[ZF] = Bits.isZero(cpu.A)
		cpu.flags[SF] = Bits.signInTwosComp(cpu.A)
		cpu.flags[PVF] = Bits.paritySet(cpu.A)
开发者ID:,项目名称:,代码行数:10,代码来源:


示例7: add_iy_rr

    def add_iy_rr(cpu, opcode, logger):
        regInd = (opcode >> 4) & 3
        val = cpu.Reg16(regInd, iy=True)

        old = cpu.IY
        cpu.IY = cpu.IY + val
        cpu.NFlag = Bits.reset()
        cpu.HFlag = Bits.carryFlagAdd16(old, cpu.IY)
        cpu.CFlag = Bits.overflow(old, cpu.IY, bits=16)
        cpu.m_cycles, cpu.t_states = 4, 15
        logger.info("ADD IY, {}".format(IndexToReg.translate16Bit(regInd)))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:11,代码来源:opcodes.py


示例8: inc8

	def inc8(cpu, opcode, logger):
		logger.info("INC r")
		index = ( opcode >> 3 ) & 7
		oldValue =  cpu.regs[index]
		cpu.regs[index] = (cpu.regs[index] + 1 ) & 0xFF

		cpu.NFlag = False
		cpu.ZFlag = Bits.isZero(cpu.regs[index])
		cpu.HFlag = Bits.halfCarrySub(oldValue, cpu.regs[index])
		cpu.PVFlag = True if oldValue == 0x7f else False
		cpu.SFlag = Bits.twos_comp(cpu.regs[index]) < 0
开发者ID:,项目名称:,代码行数:11,代码来源:


示例9: dec_at_ix_d

 def dec_at_ix_d(cpu, opcode, logger):
     d = cpu.ram[cpu.PC]
     old_val = cpu.ram[cpu.IX+d]
     new_val = old_val - 1
     cpu.ram[cpu.IX+d] = new_val
     cpu.ZFlag = Bits.isZero(new_val)
     cpu.SFlag = Bits.isNegative(new_val)
     cpu.NFlag = Bits.set()
     cpu.PVFlag = Bits.halfCarrySub(old_val, new_val)
     cpu.m_cycles, cpu.t_states = 6, 23
     logger.info("DEC (IX+{:02X})".format(d))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:11,代码来源:opcodes.py


示例10: adc_r

    def adc_r(cpu, opcode, logger):
        reg_idx = (opcode & 7)
        old_val = cpu.A
        cpu.A = old_val + cpu.regs[reg_idx] + (1 if cpu.CFlag else 0)

        cpu.SFlag = Bits.isNegative(cpu.A)
        cpu.ZFlag = Bits.isZero(cpu.A)
        cpu.NFlag = Bits.reset()

        cpu.m_cycles, cpu.t_states = 1, 4
        logger.info("ADC A, {}".format(IndexToReg.translate8Bit(reg_idx)))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:11,代码来源:opcodes.py


示例11: cp

	def cp(cpu, opcode, logger):
		regInd = opcode & 7
		logger.info(regInd)
		value = cpu.A - cpu.regs[regInd]
		"""Flags"""
		cpu.flags[ZF] = Bits.isZero(value)
		cpu.flags[CF] = Bits.carryFlag(value)
		cpu.flags[NF] = True
		cpu.flags[HF] = Bits.halfCarrySub(cpu.A, value)
		cpu.flags[SF] = Bits.signFlag(value)
		cpu.flags[PVF] = Bits.overflow(cpu.A, value)
		logger.info("CP r")
开发者ID:,项目名称:,代码行数:12,代码来源:


示例12: xorA

	def xorA(cpu, opcode, logger):
		"""XOR A"""
		regInd = opcode & 7
		cpu.A = cpu.A ^ cpu.regs[regInd]
		"""Flags"""
		cpu.flags[ZF] = Bits.isZero(cpu.A)
		cpu.flags[CF] = False
		cpu.flags[NF] = False
		cpu.flags[HF] = False
		cpu.flags[SF] = Bits.signInTwosComp(cpu.A)
		cpu.flags[PVF] = Bits.paritySet(cpu.A)
		logger.info("XOR A")
开发者ID:,项目名称:,代码行数:12,代码来源:


示例13: sub_n

    def sub_n(cpu, opcode, logger):
        n = cpu.ram[cpu.PC]
        value = cpu.A - n

        cpu.NFlag = Bits.set()
        cpu.ZFlag = Bits.isZero(value)
        cpu.HFlag = Bits.halfCarrySub(cpu.A, value)
        cpu.PVFlag = Bits.overflow(cpu.A, value)
        cpu.CFlag = Bits.carryFlag(value)
        cpu.A = value

        logger.info("SUB {:02X}".format(n))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:12,代码来源:opcodes.py


示例14: add16

    def add16(cpu, opcode, logger):
        regInd = (opcode & 0x30) >> 4
        value = cpu.Reg16(regInd)

        oldHL = cpu.HL
        cpu.HL = cpu.HL + value

        cpu.NFlag = Bits.reset()
        cpu.CFlag = Bits.carryFlag16(oldHL, cpu.HL)
        cpu.HFlag = Bits.carryFlag16(oldHL, cpu.HL, bits=11)
        cpu.m_cycles, cpu.t_states = 3, 11
        logger.info("ADD HL, {}".format(IndexToReg.translate16Bit(regInd)))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:12,代码来源:opcodes.py


示例15: inc8

    def inc8(cpu, opcode, logger):
        index = (opcode >> 3) & 7
        oldValue = cpu.regs[index]
        cpu.regs[index] = Bits.limitTo8Bits(cpu.regs[index] + 1)

        cpu.NFlag = Bits.reset()
        cpu.ZFlag = Bits.isZero(cpu.regs[index])
        cpu.HFlag = Bits.halfCarrySub(oldValue, cpu.regs[index])
        cpu.PVFlag = True if oldValue == 0x7f else False
        cpu.SFlag = Bits.isNegative(cpu.regs[index])

        cpu.m_cycles, cpu.t_states = 1, 4
        logger.info("INC {}".format(IndexToReg.translate8Bit(index)))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:13,代码来源:opcodes.py


示例16: dec8b

    def dec8b(cpu, opcode, logger):
        reg_index = (opcode >> 3) & 7
        old_val = cpu.regs[reg_index]
        cpu.regs[reg_index] = cpu.regs[reg_index] - 1

        cpu.ZFlag = Bits.isZero(cpu.regs[reg_index])
        cpu.SFlag = Bits.isNegative(cpu.regs[reg_index])
        cpu.NFlag = Bits.set()
        cpu.PVFlag = Bits.halfCarrySub(old_val, cpu.regs[reg_index])
        cpu.HFlag = Bits.halfCarrySub(old_val, cpu.regs[reg_index])

        cpu.m_cycles, cpu.t_states = 1, 4
        logger.info("DEC {}".format(IndexToReg.translate8Bit(reg_index)))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:13,代码来源:opcodes.py


示例17: dec_mem_at_iy

    def dec_mem_at_iy(cpu, opcode, logger):
        displacement = cpu.ram[cpu.PC]
        addr = cpu.IY + displacement
        value = cpu.ram[addr]
        new_value = value - 1
        cpu.ram[addr] = new_value

        cpu.NFlag = Bits.set()
        cpu.SFlag = Bits.isNegative(new_value)
        cpu.ZFlag = Bits.isZero(new_value)
        cpu.PVFlag = True if value == 0x80 else False
        cpu.HFlag = Bits.halfCarrySub(value, new_value)
        logger.info("DEC (IY+{:2X})".format(displacement))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:13,代码来源:opcodes.py


示例18: rrd

 def rrd(cpu, opcode, logger):
     low_a = cpu.A & 0x0F
     mem_hl = cpu.ram[cpu.HL]
     low_hl = mem_hl & 0x0F
     high_hl = (mem_hl & 0xF0) >> 4
     cpu.A = (cpu.A & 0xF0) | low_hl
     mem_hl = (low_a << 4) | high_hl
     cpu.ram[cpu.HL] = mem_hl
     cpu.ZFlag = Bits.isZero(cpu.A)
     cpu.SFlag = Bits.isNegative(cpu.A)
     cpu.HFlag = Bits.reset()
     cpu.NFlag = Bits.reset()
     cpu.PVFlag = Bits.isEvenParity(cpu.A)
     cpu.m_cycles, cpu.t_states = 5, 18
     logger.info("RRD")
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:15,代码来源:opcodes.py


示例19: test_add_a_e_with_C_flag_set_correctly_caluclates_value

 def test_add_a_e_with_C_flag_set_correctly_caluclates_value(self):
     cpu = CPU(ROM('\x8b'))
     cpu.A = 0x22
     cpu.E = 0x66
     cpu.CFlag = Bits.set()
     cpu.readOp()
     self.assertEqual(0x89, cpu.A)
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:7,代码来源:tests_adc.py


示例20: jr_e

    def jr_e(cpu, opcode, logger):
        pc = cpu.PC
        jumpOffset = Bits.twos_comp(cpu.ram[pc])

        cpu.PC = pc + jumpOffset + 1
        cpu.m_cycles, cpu.t_states = 3, 12
        logger.info("JR {0:x}".format(jumpOffset))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:7,代码来源:opcodes.py



注:本文中的utility.Bits类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utility.CtfUtil类代码示例发布时间:2022-05-26
下一篇:
Python utility.temp_dir函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap