Hacker News new | ask | show | jobs
by ssdsa 4176 days ago
On 6502, JMP uses 3 cycles. A branch uses 3 cycles if no page boundary is crossed, and 4 cycles if a page boundary is crossed. So there, JMP is "faster".
2 comments

Ok, on 6502, you might be right (if your numbers are correct). But the 3 cycles might have been, because a decision according flags had to be made -- so a newer processor could have made an unconditional branch faster.
Perhaps wasting a single byte was regarded as a bad programming choice... :)
There is also an other reason for not wasting "a single byte":

Branches are the only Jumps with condition. So, when you have a far destination that is more than 127 bytes away, you have to do that:

   want to do:
            BCS far_dest

   Have to do:
            BCC no_jump
            JMP far_dest
    no_jmp: ...
So, when you wasted to many "single bytes", you may end up up adding 3 Bytes and at least 3 cycles to your conditional jumps.
When you are space constrained, there is no ":-)" on that.

-- veteran of several game cartridges for the 6502

That is correct. Also, when you see, how much space was available. On Commodore, the Basic had to fit into 8k+ (together with the "Kernel" it had 16k of Rom and the Kernel needed ~7k) -- so space was really scarce -- a bigger ROM would have made the computers more costly.