3 ms·
That is right. The JMP is a jump, because it takes a full 16bit address. Branches where all relative (-128 .. +127 bytes relative to current PC). I am not sure,
by PythonicAlpha 12y ago
That is right. The JMP is a jump, because it takes a full 16bit address. Branches where all relative (-128 .. +127 bytes relative to current PC). I am not sure, but it also is very probable, that branches are faster -- at least the processor had to fetch one byte less. That should be the other reason, that newer processors had the unconditional versions.
That was one hacking thing in these days: finding flags that are guaranteed to be set or cleared to use as condition for a branch instruction. I remember, that I always tried to avoid JMPs.
- ssdsa 12y agoOn 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".
- aruggirello 12y agoPerhaps wasting a single byte was regarded as a bad programming choice... :)
- kabdib 12y agoWhen you are space constrained, there is no ":-)" on that. -- veteran of several game cartridges for the 6502
- PythonicAlpha 12y agoThat 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.
- PythonicAlpha 12y agoThere 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.
- PythonicAlpha 12y agoOk, 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.