djipi / Virtual-Jaguar-Rx

Virtual Jaguar, an Atari Jaguar emulator, with integrated debugger
GNU General Public License v3.0
42 stars 5 forks source link

M68K disassembly displays wrong instruction #30

Open djipi opened 3 years ago

djipi commented 3 years ago

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.

djipi commented 3 years ago

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

42Bastian commented 2 years ago

moveq and move sr,dx are also wrong disassembled.

djipi commented 2 years ago

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.

42Bastian commented 2 years ago

I will make one this evening.

42Bastian commented 2 years ago

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

djipi commented 2 years ago

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.

42Bastian commented 2 years ago

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

djipi commented 2 years ago

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

42Bastian commented 2 years ago

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

djipi commented 2 years ago

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.

42Bastian commented 2 years ago

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.

djipi commented 2 years ago

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