Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Instruction Parsing Problems #38

Open
Kneesnap opened this issue Dec 31, 2020 · 10 comments
Open

Instruction Parsing Problems #38

Kneesnap opened this issue Dec 31, 2020 · 10 comments

Comments

@Kneesnap
Copy link

It seems at least one instruction is not parsed properly by Ghidra.
I have built a .S file. When I open the resulting ELF file in Ghidra, it misidentifies some of the instructions.

The .S file:
image

Ghidra
image

NOTE: The reason the .S file looks funky is because it's auto-generated.

@Kneesnap
Copy link
Author

Another Instruction:
image
image

@astrelsky
Copy link
Contributor

These are all correct. They are simplified. For example daddu v0, zero, zero is v0 = 0 + 0 which is the same as dmove v0, 0 or
v0 = 0

@Kneesnap
Copy link
Author

dmove is not a valid instruction in the emotion engine though. That's the problem.

@astrelsky
Copy link
Contributor

Capture

@Kneesnap
Copy link
Author

Kneesnap commented Jan 2, 2021

Just because it shows up in an emulator doesn't mean it's valid. Neither the official PS2 instruction set documentation, nor the PS2SDK recognize either qmove or dmove as valid instructions.

image

@astrelsky
Copy link
Contributor

@beardypig

@asmblur
Copy link

asmblur commented Mar 20, 2021

I think it would be nice to have an option to disable those macros.

@beardypig
Copy link
Owner

beardypig commented Apr 29, 2021

I don't think it would be very easy to add an option to enable/disable these instructions because of how sleigh works, but I might be wrong.
They were borrowed from other instruction sets to simplify the decompilation results, similar to what pcsx2 has in their debugger. I never intended for the decompiled output from this extension to be reused, but if people will find it more useful to use the strict instruction set then it can be changed.

We could remove them as they may no longer be required - but, my guess is that it would be a breaking change and might break existing projects.

Edit: upon further investigation, we could make this pseudo instructions optional using a flag.

@Mc-muffin
Copy link

Just because it shows up in an emulator doesn't mean it's valid. Neither the official PS2 instruction set documentation, nor the PS2SDK recognize either qmove or dmove as valid instructions.

image

Just as a reference, PCSX2's debugger was implemented by the same person that made armips, and as such it has some macros defined, but you can still view the un-macro'd instrunctions (and the bytes they are decoded from) by pressing tab in the assembly view

@astrelsky
Copy link
Contributor

I don't think it would be very easy to add an option to enable/disable these instructions because of how sleigh works, but I might be wrong.
They were borrowed from other instruction sets to simplify the decompilation results, similar to what pcsx2 has in their debugger. I never intended for the decompiled output from this extension to be reused, but if people will find it more useful to use the strict instruction set then it can be changed.

We could remove them as they may no longer be required - but, my guess is that it would be a breaking change and might break existing projects.

Edit: upon further investigation, we could make this pseudo instructions optional using a flag.

We could. Not sure if we mean the same thing, but we could also use the context register. You would need to redisassemble to see the changes though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants