当前位置: 首页>>代码示例>>Python>>正文


Python Bits.twos_comp方法代码示例

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


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

示例1: sbc

# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import twos_comp [as 别名]
	def sbc(cpu, opcode, logger):
		logger.info("SBC HL")
		regInd = (opcode & 0x30) >> 4
		value = 0
		if regInd == 0:
			value = cpu.BC
		elif regInd == 1:
			value = cpu.DE
		elif regInd == 2:
			value = cpu.HL
		elif regInd == 3:
			value = cpu.SP

		oldHL = cpu.HL
		logger.info("Old value of HL: " + str(oldHL))
		cpu.HL = cpu.HL - value - (1 if cpu.CFlag else 0)
		logger.info("New value of HL: " + str(cpu.HL))

		cpu.flags[SF] = Bits.signFlag(cpu.HL, bits=16)
		cpu.flags[ZF] = Bits.isZero(cpu.HL)
		cpu.flags[HF] = Bits.halfCarrySub16(oldHL, cpu.HL)
		cpu.flags[PVF] = Bits.overflow(Bits.twos_comp(oldHL, bits=16), 
									   Bits.twos_comp(cpu.HL, bits=16))
		cpu.flags[NF] = True
		cpu.flags[CF] = Bits.borrow(cpu.HL, bits=16)
开发者ID:,项目名称:,代码行数:27,代码来源:

示例2: jr_e

# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import twos_comp [as 别名]
    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,代码行数:9,代码来源:opcodes.py

示例3: jpnc

# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import twos_comp [as 别名]
	def jpnc(cpu, opcode, logger):
		jumpOffset = Bits.twos_comp(cpu.rom.readMemory(cpu.PC)) - 2
		if cpu.CFlag:
			return

		cpu.PC = cpu.PC + jumpOffset
		logger.info("JP NC {0:x}".format(jumpOffset))
开发者ID:,项目名称:,代码行数:9,代码来源:

示例4: jpnz

# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import twos_comp [as 别名]
	def jpnz(cpu, opcode, logger):
		jumpOffset = cpu.rom.readMemory(cpu.PC)
		if cpu.ZFlag:
			return

		cpu.PC = cpu.PC + Bits.twos_comp(jumpOffset)
		logger.info("JPNZ {0:x}".format(jumpOffset))
开发者ID:,项目名称:,代码行数:9,代码来源:

示例5: jrz

# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import twos_comp [as 别名]
	def jrz(cpu, opcode, logger):

		jumpOffset = Bits.twos_comp(cpu.rom.readMemory(cpu.PC))
		if cpu.ZFlag == False:
			return

		cpu.PC = cpu.PC + jumpOffset
		logger.info("JR Z {0:x}".format(jumpOffset))
开发者ID:,项目名称:,代码行数:10,代码来源:

示例6: jr_c

# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import twos_comp [as 别名]
 def jr_c(cpu, opcode, logger):
     pc = cpu.PC + 1
     jumpOffset = Bits.twos_comp(cpu.ram[pc]) - 2
     no_jump = cpu.CFlag is False
     pc = pc + jumpOffset
     if not no_jump:
         cpu.PC = pc
         cpu.m_cycles, cpu.t_states = 1, 5
     cpu.m_cycles, cpu.t_states = 2, 7
     logger.info("JP C {0:04X}".format(pc))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:12,代码来源:opcodes.py

示例7: djnz

# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import twos_comp [as 别名]
    def djnz(cpu, opcode, logger):
        pc = cpu.PC
        e = cpu.ram[pc]
        cpu.B = cpu.B - 1
        pc = pc + Bits.twos_comp(e) + 1
        if cpu.B != 0:
            cpu.m_cycles, cpu.t_states = 1, 5
            cpu.PC = pc

        cpu.m_cycles, cpu.t_states = 2, 8
        logger.info("DJNZ {:04X}".format(pc))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:13,代码来源:opcodes.py

示例8: inc8

# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import twos_comp [as 别名]
	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:,项目名称:,代码行数:13,代码来源:

示例9: jrz

# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import twos_comp [as 别名]
    def jrz(cpu, opcode, logger):
        pc = cpu.PC
        jumpTo = pc + Bits.twos_comp(cpu.ram[pc]) + 1

        no_jump = cpu.ZFlag is False

        if not no_jump:
            cpu.PC = jumpTo
            cpu.m_cycles, cpu.t_states = 1, 5

        cpu.m_cycles, cpu.t_states = 2, 7
        logger.info("JR Z, {:04X}".format(jumpTo))
开发者ID:pawlos,项目名称:Timex.Emu,代码行数:14,代码来源:opcodes.py

示例10: jpnc

# 需要导入模块: from utility import Bits [as 别名]
# 或者: from utility.Bits import twos_comp [as 别名]
    def jpnc(cpu, opcode, logger):
        pc = cpu.PC
        jumpOffset = Bits.twos_comp(cpu.ram[pc])

        no_jump = cpu.CFlag

        if not no_jump:
            cpu.PC = pc + jumpOffset+1
            cpu.m_cycles, cpu.t_states = 1, 5

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


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