mkst / maspsx

MIT License
5 stars 4 forks source link

`nop` inserted after `mflo` in expanded `div` may be ASPSX-version-specific #76

Closed abelbriggs1 closed 4 months ago

abelbriggs1 commented 4 months ago

Example scratch: https://decomp.me/scratch/pCyrJ

Before MASPSX:

    divu    $2,$2,$3
    sh  $2,gUpdateRate

After MASPSX:

    # EXPAND_DIVU START
    .set    noat
    divu    $zero,$2,$3
    bnez    $3,.L_NOT_DIV_BY_ZERO_195
    nop
    break   0x7
.L_NOT_DIV_BY_ZERO_195:
    mflo    $2
    .set    at
    # EXPAND_DIVU END
    nop  # DEBUG: divu and next_instruction (sh $2,gUpdateRate) loads from $2

    sh  $2,gUpdateRate

With the above scratch, the # DEBUG NOP is only inserted by MASPSX and PSYQ3.3 (ASPSX 2.21). Later versions of PSYQ, such as PSYQ3.6 (the original compiler for the scratch in question) do not seem to insert the NOP here.

mkst commented 4 months ago

Thank you for raising the issue, I've found the problem and had a go at fixing it (see this branch). I'll likely merge this tomorrow and get it deployed to decomp.me over the weekend.

abelbriggs1 commented 4 months ago

Tested your branch and the fix looks like it's working on my local decomp repo (which contains that scratch's code).