Is the disassembler discontinued

Other misc things
Post Reply
MikeLynx
New member
Posts: 5
Joined: Thu Feb 25, 2021 10:52 am

Is the disassembler discontinued

Post by MikeLynx »

I have discovered a bug in the disassembler and I was just wondering if the disassembler is still active or discontinued, and whether I need to submit a new issue on github?

The issue is that the disassembler is producing the following statements:

LD (IX+$04),$00
LD (IX+$04),$01
LD (IX-$01),$02

whereas it should be outputting:

LD (IX+$00),$04
LD (IX+$01),$04
LD (IX+$02),$0FF

(the operands have been flipped)

Thanks,

Mike.
User avatar
dom
Well known member
Posts: 1506
Joined: Sun Jul 15, 2007 10:01 pm

Re: Is the disassembler discontinued

Post by dom »

Which disassembler are you referring to? I've just checked z88dk-dis and it seems to be handling these correctly.
MikeLynx
New member
Posts: 5
Joined: Thu Feb 25, 2021 10:52 am

Re: Is the disassembler discontinued

Post by MikeLynx »

dom wrote: Mon Oct 11, 2021 7:12 pm Which disassembler are you referring to? I've just checked z88dk-dis and it seems to be handling these correctly.
OK. Thanks. I'll investigate my version further and report back...perhaps I need a refresh?
User avatar
dom
Well known member
Posts: 1506
Joined: Sun Jul 15, 2007 10:01 pm

Re: Is the disassembler discontinued

Post by dom »

MikeLynx wrote: Mon Oct 11, 2021 10:39 pmOK. Thanks. I'll investigate my version further and report back...perhaps I need a refresh?
I don't think it's ever been broken which is odd.

Code: Select all

% cat test.asm
	ld	(ix+10),2
	ld	(ix-20),$dd
	
% hexdump test.bin
0000000 dd 36 0a 02 dd 36 ec dd

% z88dk-dis test.bin
                    ld      (ix+$0a),$02                    ;[0000] dd 36 0a 02
                    ld      (ix-$14),$dd                    ;[0004] dd 36 ec dd	
stefano
Well known member
Posts: 1695
Joined: Mon Jul 16, 2007 7:39 pm

Re: Is the disassembler discontinued

Post by stefano »

could Mike be disassembling zx81 code? That -ixiy swap trick is sometimes confusing.
MikeLynx
New member
Posts: 5
Joined: Thu Feb 25, 2021 10:52 am

Re: Is the disassembler discontinued

Post by MikeLynx »

Ok, sorry for the delay in getting back to this. These are my steps. My assembly file is as follows:

Code: Select all

LD (IX+$00),$04
LD (IX+$01),$04
LD (IX+$02),$0FF
I assemble it using the command:

Code: Select all

z88dk-z80asm -mz80 -b test.asm
This produces a test.bin file, which I disassemble using:

Code: Select all

z88dk-dis -mz80 test.bin
Which produces this:

Code: Select all

                    ld      (ix+$04),$00                    ;[0000] dd 36 00 04
                    ld      (ix+$04),$01                    ;[0004] dd 36 01 04
                    ld      (ix-$01),$02                    ;[0008] dd 36 02 ff
Unfortunately, as you can see, the opcodes are swapped. My z88dk install is dated 24/03/2021. I don't recall if I downloaded my binaries or built from source code.

Strange. Thanks.
User avatar
dom
Well known member
Posts: 1506
Joined: Sun Jul 15, 2007 10:01 pm

Re: Is the disassembler discontinued

Post by dom »

I rolled back to March to see if I could reproduce this but unfortunately not. Given that there's been no changes since then I'm not too surprised about that.

I've spent a while staring at this line:

Code: Select all

                        BUF_PRINTF("%-8s%s,%s", "ld", handle_register8(state, y,opbuf1,sizeof(opbuf1)), handle_immed8(state, opbuf2, sizeof(opbuf2)));
And I can only think that we're fallen in the void that is "undefined behaviour". In fact, I'm pretty certain it's that: the order of the evaluation of the arguments is implementation specific. In this case state is mutated (i.e PC incremented) by each of the handle_ functions.

So, I'll fix that, but important questions: CPU, OS and compiler that you've spotted this on.
cborn
Member
Posts: 84
Joined: Tue Oct 06, 2020 7:45 pm

Re: Is the disassembler discontinued

Post by cborn »

hello,
as nono i like to try and i have an identical outcome

Code: Select all

$ z88dk-z80asm -mz80 -b test.asm
$ z88dk-dis -mz80 test.bin
                    ld      (ix+$04),$00                    ;[0000] dd 36 00 04
                    ld      (ix+$04),$01                    ;[0004] dd 36 01 04
                    ld      (ix-$01),$02                    ;[0008] dd 36 02 ff
i work with linux debian 10 which natively uses gcc 8.3.0,posix.

Code: Select all

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6) 
User avatar
dom
Well known member
Posts: 1506
Joined: Sun Jul 15, 2007 10:01 pm

Re: Is the disassembler discontinued

Post by dom »

cborn wrote: Tue Oct 19, 2021 9:18 pmi work with linux debian 10 which natively uses gcc 8.3.0,posix.
Wonderful, thank you for the hint. I can now see it and can verify that I've fixed it as well.
MikeLynx
New member
Posts: 5
Joined: Thu Feb 25, 2021 10:52 am

Re: Is the disassembler discontinued

Post by MikeLynx »

dom wrote: Tue Oct 19, 2021 8:44 pm So, I'll fix that, but important questions: CPU, OS and compiler that you've spotted this on.
Thanks, Dom!

I am using a PC: Windows 7 Ultimate N Service Pack 1 (64 bit) on an Intel Core 2 Duo.

Cheers,

Mike.
MikeLynx
New member
Posts: 5
Joined: Thu Feb 25, 2021 10:52 am

Re: Is the disassembler discontinued

Post by MikeLynx »

This is working now in my environment. (as you have probably guessed!)

Thanks again for the fix.
Post Reply