View Single Post
Old 16th Jan 2017, 11:03 am   #12
jjl
Octode
 
jjl's Avatar
 
Join Date: Jan 2003
Location: Ware, Herts. UK.
Posts: 1,082
Default Re: They don't come much more Vintage than this

Quote:
Originally Posted by julie_m View Post
Yet one more common optimisation you can do by hand on the Z-80 and the 6502 is to use a two-byte relative jump (which happens only to be available as a conditional instruction), if you know in advance that the processor state will always be favourable (e.g., a SUBtract or DECrease instruction will always leave the carry flag set if it produced a positive value), as opposed to a three-byte unconditional absolute jump.
No need to do this on the Z80 as it has a 2 byte unconditional relative jump instruction i.e.

JR xx

with the opcode 18H in the first byte and 2s complement offset in the second.

I too am mystified about the statement that programming in assembly language is somehow less efficient than programming in machine code. If they felt so inclined, the assembly language programmer could employ any of the tricks stated above.

John

Last edited by jjl; 16th Jan 2017 at 11:10 am.
jjl is offline