Menu

#3275 Undocumented instructions not working in z80 assembler

closed-fixed
None
sdas
5
2023-01-27
2021-08-25
No

This code

.z80
.allow_undocumented
ld  a, iyl

gives the error

test.s:2: Error: <o> .org in REL area or directive / mnemonic error
test.s:3: Error: <a> machine specific addressing or addressing mode error
removing

Interestingly, it works with .z180 instead of .z80 (where it is less useful - AFAIK the z180 does trap on undocumented instructions).

Related

Wiki: NGI0-SDCC
Commit: [a9f988]

Discussion

  • Ragozini Arturo

    Ragozini Arturo - 2022-03-14

    The bug is unresolved, the .allow_undocumented directive is not working.

     
    • Sebastian Riedel

      Yes, it looks broken.
      Since Z80N looks like being a superset of Z80, you could use .zxn as a workaround for handwritten asm.
      .zxn and .ez80 enable undocumented instructions by default.

       

      Last edit: Sebastian Riedel 2022-03-15
  • Sebastian Riedel

    Now it says:

    test.asm:2: Error: <o> Internal Opcode Error.
    test.asm:3: Error: <a> Invalid Addressing Mode.
    

    I had to fix the error printing first for tracking it down. sdas printed general error messages instead of using the strings actually thrown.

    Internal Opcode Error means case X_UNDOCD: does not trigger at all.

     
    • Sebastian Riedel

              case X_Z80:
                      if (rf > S_CPU)
                              rf = 0;
                      break;
      
      #define S_CPU   83
      #define S_RL_UNDOCD  85
      #define X_UNDOCD 89
      

      .allow_undocumented and sll were intentionally or accidentally disabled for z80.

       
      • Sebastian Riedel

        Should be fixed in [r13287]

            .z80
            .allow_undocumented
            sll a
            ld  a, iyl
        
        $ sdasz80 test.asm
        
            .z80
            ;.allow_undocumented
            sll a
            ld  a, iyl
        
        $ sdasz80 test.asm
        test.asm:3: Error: <a> Undocumented instructions not enabled.
        test.asm:4: Error: <a> Invalid Addressing Mode.
        
         

        Related

        Commit: [r13287]

  • Sebastian Riedel

    AFAIK the z180 does trap on undocumented instructions).

    What does hd64180 on undocumented instructions? I could throw an error if one tries to enable .allow_undocumented on these targets.

    But only if that’s the case on hd64180 and z180, because they are the same for asz80.

     

    Last edit: Sebastian Riedel 2022-03-24
    • Sebastian Riedel

      Since they both trap, I disabled it in [r13296]

       

      Related

      Commit: [r13296]

  • Aoineko

    Aoineko - 2022-06-12

    I didn't understand if .allow_undocumented is supposed to work or not after all?
    Anyway, if I try to add this directive to my assembler code, I get this error:
    Error: <o> .org in REL area or directive / mnemonic error

     
    • Philipp Klaus Krause

      AFAIK, it is working in current snaphots (or SDCC built from source) since late March. It works for me. In SDCC 4.2.0 it AFAIK was still broken.

       
      • Sebastian Riedel

        Though for 4.2.0 the .zxn workaround described above should work.

         
  • Philipp Klaus Krause

    Can you confirm that this works for you in a current snapshot?

     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
    • assigned_to: Philipp Klaus Krause
     

Log in to post a comment.