Virtual-Jaguar-Rx icon indicating copy to clipboard operation
Virtual-Jaguar-Rx copied to clipboard

M68K disassembly displays wrong instruction

Open djipi opened this issue 4 years ago • 12 comments

User reports a display disassembly error but the opcode is correct and correctly executed. Problem occurs also in the M68K Disassembly Browser, available in the debug Alpine mode. It is also a legacy issue, occuring in Virtual Jaguar 2.1.2.

  • Source code: move.l d0,(a0)+ move.l d1,(a0)+ movem.l d0-d1,bmpupdate

  • Disassembly: MOVE.L D0, (A0)+ MOVE.L D1, (A0)+ MVMLE.L A6-A7, $9108

  • Listing 8021EC: 20C0 | MOVE.L D0, (A0)+ 8021EE: 20C1 | MOVE.L D1, (A0)+ 8021F0: 48F9 0003 0001 6C28 | MVMLE.L A6-A7, bmpupdate

djipi avatar May 15 '21 17:05 djipi

M68KDisassemble() function in m68kdasm.c is a good start to look at the problem. Problem has been spoted in the function ShowEA() within case imm1.

Depend the situation HandleMovem(buffer, offset, 1) is correct but for our case it should be 0 instead of 1.

Exemple of correct usage with parameter as 1: 48E7 7880 MVMLE.L D1-D4/A0, -(A7) 48E7 C080 MVMLE.L D0-D1/A0, -(A7) And as 0: 4CDF 011E MVMEL.L (A7)+, D1-D4/A0 4CDF 0103 MVMEL.L (A7)+, D0-D1/A0

djipi avatar May 15 '21 17:05 djipi

moveq and move sr,dx are also wrong disassembled.

42Bastian avatar Mar 31 '22 03:03 42Bastian

This is good to know, and I guess it occurs also in the original Virtual Jaguar 2.1.2 / 2.1.3. Could you provide a (small) binary using moveq and move sr,dx? It can help to investigate.

djipi avatar Mar 31 '22 04:03 djipi

I will make one this evening.

42Bastian avatar Mar 31 '22 04:03 42Bastian

Sorry, to tired. Anyway here the source and cof for the moveq and move ..,sr problem. disass.zip

42Bastian avatar Apr 01 '22 05:04 42Bastian

Sorry, to tired. Anyway here the source and cof for the moveq and move ..,sr problem. disass.zip

No problems, thank you for the file. I do not promise a fix but I will look at it for sure.

djipi avatar Apr 01 '22 06:04 djipi

No problem. Just collecting issues ;-) It is not the most urgent one.

42Bastian avatar Apr 01 '22 06:04 42Bastian

Looked at the moveq issue and to make it "short", 2 problems arise.

  1. The dasm is looking for .B, .W or .L to handle the move, so moveq will require a specific treatment for the dasm. -- The dasm considers the moveq as move.l because it simplify the treatment.
  2. It will require an additional dasm type size to represent the moveq instruction.

It is possible to fix the moveq in the dasm within a cautious approach. At time of writing, 2 functions needs to be modified: M68KDisassemble & build_insn

djipi avatar Jul 18 '22 18:07 djipi

Looked into the 68000 folder, wow, this is not an easy change :(

42Bastian avatar Jul 19 '22 04:07 42Bastian

Looked into the 68000 folder, wow, this is not an easy change :(

VJ's 68000 emulation has been ported from the UAE 68000 cpu core. May be their Amiga emulator got updates since then.

djipi avatar Jul 19 '22 15:07 djipi

Just checked https://github.com/tonioni/WinUAE/blob/master/table68k and I see no chance to merge it unless you want to spend a lot of time testing if nothing is broken.

42Bastian avatar Jul 19 '22 16:07 42Bastian

James Hammons did the port for the Atari Jaguar many years ago, but unsure if he is still active on the console.

djipi avatar Jul 20 '22 17:07 djipi