Menu

#441 [z80] disallowed undocumented instructions

None
closed-accepted
None
5
2022-11-04
2022-10-06
Job Bolle
No

Peephole rule 174b (and possibly others?) can generate iyl/iyh instructions when not allowed.
This is because the canSplitReg() restriction splits iy into iyl/iyh.

This problem goes away by testing for HAS_IYL_INST instead of !IS_SM83 in z80canSplitReg()

--- a/src/z80/peep.c
+++ b/src/z80/peep.c
@@ -1294,7 +1294,7 @@ bool z80canSplitReg (const char *reg, char dst[][16], int nDst)
           dst[i][1] = '\0';
         }
     }
-  else if (!IS_SM83 && (!strcmp (reg, "ix") || !strcmp (reg, "iy")))
+  else if (HAS_IYL_INST && (!strcmp (reg, "ix") || !strcmp (reg, "iy")))
     {
       for (i = 0; i < nDst; ++i)
         {

Related

Wiki: z80

Discussion

  • Job Bolle

    Job Bolle - 2022-10-21

    Example to reproduce:

    sdcc -mz80 --max-allocs-per-node 50000 -c device/lib/_fsadd.c
    _fsadd.asm:512: Error: <a> Invalid Addressing Mode.
    _fsadd.asm:513: Error: <a> Invalid Addressing Mode.
    removing _fsadd.rel
    
    509:        jr  00142$
    510:    00141$:
    511:        ld  bc, #0x0000
    512:        ld  iyh, b
    513:        ld  iyl, c
    514:    00142$:
    515:        ld  e, -9 (ix)
    516:        ld  a, -8 (ix)
    
     
  • Job Bolle

    Job Bolle - 2022-10-29

    ... additionally, this replacement is not an optimization:

    ld  iy, #0x0000  ; 4B, 14T
    
    ld  iyh, b       ; 2B,  8T
    ld  iyl, c       ; 2B,  8T
    

    It is not smaller, and it takes 2 more cycles.

     
  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
    • Group: -->
     
  • Philipp Klaus Krause

    • status: open --> closed-accepted
     
  • Philipp Klaus Krause

    These issues should be fixed in [r13742].

     

    Related

    Commit: [r13742]

  • Job Bolle

    Job Bolle - 2022-11-04

    peep rule 174a now has the notSame(%1 'ix' 'iy') and notSame(%2 'ix' 'iy') restrictions twice.

     
    • Philipp Klaus Krause

      Thanks. Fixed in [r13744].

       

      Related

      Commit: [r13744]


Log in to post a comment.