pspdev / binutils-gdb

binutils with PSP patch applied
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git
GNU General Public License v2.0
2 stars 2 forks source link

PSP VFPU instructions `vpfxs` and family should not require brackets #9

Open bismurphy opened 2 hours ago

bismurphy commented 2 hours ago

I am attempting to assemble some disassembled official PSP code. In the disassembly, I have a few instructions of vpfxs (as well as vpfxt and vpfxd). They have a syntax like:

vpfxs 2, 1, 1, -2

However, the psp-as in this repository fails to assemble this instruction, and says "Error: invalid operands `vpfxs 2,1,1,-2'"

Through some testing, I have determined that this is because the psp-as requires brackets around the operands. vpfxs [2, 1, 1, -2] succeeds.

According to the official Sony docs at https://github.com/Decompollaborate/rabbitizer/files/11356335/VFPU-Instruction_Manual-English.pdf (page 272), this instruction should have 4 operands, but there is no bracketing around them. I believe the psp-as is requiring brackets that, according to the specification, should not exist.

I do not have enough familiarity with the instruction processing code to understand why these brackets are needed. It is possible that I am misunderstanding the documentation, but it doesn't seem like there should be any brackets in the operands. This is causing the binutils-gdb assembler to be incompatible with other tools (including existing disassemblers), and it would be great if it could follow the standard and be compatible.

I did notice that the instruction definitions (here: https://github.com/pspdev/binutils-gdb/blob/1bf9b3f9be9d82cc89374ca916cd4e8e6115dcf8/opcodes/mips-opc.c#L3545) have a "k0" and "k1" listed; I'm not sure if those are creating the brackets. The definition syntax is a bit opaque.

An easy minimal example to use is: echo "vpfxs 2, 1, 1, -2" | pspdev/bin/psp-as -EL -march=allegrex -mabi=32 -Iinclude -o assembled_result.o -G0 echo "vpfxs [2, 1, 1, -2]" | pspdev/bin/psp-as -EL -march=allegrex -mabi=32 -Iinclude -o assembled_result.o -G0

The first throws an operand error, the second builds successfully. If I am reading the documentation properly, this is the opposite of the proper behavior.

bismurphy commented 2 hours ago

This repo doesn't have much activity, so I'll go ahead and ping @fjtrujy who seems to be the primary contributor :) Not trying to be too much of a bother, just don't want things to go unseen. Thanks!

fjtrujy commented 53 minutes ago

@davidgfnet is our man here!