Menu

#4009 z80MightRead unknown asm inst line: exx

closed-fixed
other
5
2026-06-14
2026-06-10
Under4Mhz
No

When I use exx or ex af,af in an peep-file I get the below error. It doesn't seem to be a problem since it does the substitution and compiles correctly.

I think this should be removed/resolved since it is not correct, at least from the programmer's perspective. It works and it is correct Z80 assembler.

z80MightRead unknown asm inst line: exx
/// GPL 2.0 or later
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>

int another_one(int a) { return a + 2; }

void do_something(int a) {

    int count = 3;

    do {

        a = another_one(a);
    } while( --count );
}

void main() {

    do_something(3);
}
# This is just an example to show the error, not a typical use case
replace {
    push    bc
    call    _another_one
    ex  de, hl
    pop bc
} by {
    exx
    call    _another_one
    exx
    ex  de, hl
}
sdcc -mz80 --peep-file peep.txt ./asm_noise.c  -o asm_noise.ihx 

Discussion

  • Under4Mhz

    Under4Mhz - 2026-06-10
    $ sdcc -mz80 --peep-file peep.txt ./asm_noise.c  -o asm_noise.ihx
    z80MightRead unknown asm inst line: exx
    
     
  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    I can reproduce the issue using the current next branch, and have a fix prepared that I'm now testing.

     
  • Philipp Klaus Krause

    • labels: --> z80, peephole optimizer
    • status: open --> pending-fixed
     
  • Philipp Klaus Krause

    Fixed in the next branch in [r16604]. While I don't consider this important enough to delay SDCC 4.6.0 RC2,, [bugs:#4007] and [bugs:#4008] might be, if we delay RC2 for fixing those, we could also get the fix for this issue into RC2.

     

    Related

    Bugs: #4007
    Bugs: #4008
    Commit: [r16604]

  • Philipp Klaus Krause

    • status: pending-fixed --> closed-fixed
     
  • Philipp Klaus Krause

    The next branch has been merged to trunk, and the fix is in SDCC 4.6.0 RC2.

     

Log in to post a comment.

MongoDB Logo MongoDB