mirror of
https://github.com/mnaberez/py65.git
synced 2025-01-23 04:32:06 +00:00
bugfix: long standing branch bug in assembler and disassembler
This commit is contained in:
parent
df41a78c9c
commit
edd730bb6e
@ -57,9 +57,8 @@ class Assembler:
|
||||
# relative branch
|
||||
absolute = int(''.join(operands), 16)
|
||||
relative = (absolute - pc) - 2
|
||||
if (relative < 1):
|
||||
relative = (relative ^ 0xFF) + 1
|
||||
operands = [ ('%02x' % relative) ]
|
||||
relative = relative & 0xFF
|
||||
operands = [ ("%02x" % relative) ]
|
||||
|
||||
elif len(operands) == 2:
|
||||
# swap bytes
|
||||
|
@ -73,8 +73,8 @@ class Disassembler:
|
||||
elif addressing == 'rel':
|
||||
opv = self._mpu.ByteAt(pc + 1)
|
||||
targ = pc + 2
|
||||
if opv & 128:
|
||||
targ -= (opv ^ 255) + 1
|
||||
if opv & (1<<(8-1)):
|
||||
targ -= (opv ^ 0xFF) + 1
|
||||
else:
|
||||
targ += opv
|
||||
targ &= 0xffff
|
||||
|
@ -229,7 +229,7 @@ class Monitor(cmd.Cmd):
|
||||
return
|
||||
|
||||
# assemble into memory
|
||||
bytes = self._assembler.assemble(line)
|
||||
bytes = self._assembler.assemble(line, pc=start)
|
||||
if bytes is None:
|
||||
self.stdout.write("\r$%04x ???\n" % start)
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user