The objective is to do some instructions optimizing space (and time also where possible),
In particular DO "dec d" and "ld c',l" (the alternate c register with the standard l, that require to make additional ld),
JUST IF "(b=x1xx1xxx and l=z010xxxx) or (b=x1xx0xxx and l=z101xxxx)" - where x means whatever value, z means that the value there is known a priori and is zero, and 0 and 1 means that that bits should be exactly that values
Register a and flags can be destroied together with hl' (the alternate one), the others should keep the original values.
Note: I can swap the usage of the 6th bit of b with one of the other of the higher nibble (7th-4th) if useful for the solution.
Initial attempt pretty long is:
Code: Select all
bit 6,b jr z,skip ld a,l and $70 bit 3,b jr nz,check2 sub $50 jr z,doit jr skip check2: sub $20 jr nz,skip doit: ld a,l exx ld c,a exx dec d skip: