mnaberez / py65

Emulate 6502-based microcomputer systems in Python
BSD 3-Clause "New" or "Revised" License
234 stars 68 forks source link

Fix branching issue with assembler. #35

Closed 6502cloud closed 7 years ago

6502cloud commented 7 years ago

Branching offsets were always off by two when assembled.

BigEd commented 7 years ago

The behaviour looks correct to me. Can you give more details of the problem?

$ env PYTHONPATH=. python ./py65/monitor.py

Py65 Monitor

       PC  AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110000
registers pc=600
.
       PC  AC XR YR SP NV-BDIZC
6502: 0600 00 00 00 ff 00110000
assemble
$0600  d0 00     BNE $0602    
$0602  d0 fc     BNE $0600    
$0604  d0 fe     BNE $0604    
6502cloud commented 7 years ago

Yeah, you are correct. I had a bug in my assembler function that was causing things to be off by 2. My PC counter wasn't incremented in the correct spot.