johanberntsson / ozmoo

A Z-machine interpreter for the Commodore 64 and similar computers
GNU General Public License v2.0
117 stars 19 forks source link

Possible micro-optimisation in screen.asm #69

Closed ZornsLemma closed 4 months ago

ZornsLemma commented 4 months ago

There are two copies of the following code sequence in screen.asm:

    jsr z_get_low_global_variable_value
    stx z_operand_value_low_arr
    sta z_operand_value_high_arr
    jsr z_ins_print_num

By moving the first three instructions to immediately before z_ins_print_num (so they can fall through into it), seven bytes can be saved. If the sequence is labelled something like "print_low_global_variable_value" I don't think this even harms readability.

fredrikr commented 4 months ago

Good idea, thanks. Done.