mkst / maspsx

MIT License
5 stars 4 forks source link

maspsx is using $at when it shouldn't #59

Closed mkst closed 6 months ago

mkst commented 6 months ago

This scratch has a call to $at where it should just use $v1.

I feel like we shouldn't need to load the immediate value into a register?

image

    jal SetExternalTransitionForce
    move    $7,$0
    .set    macro
    .set    reorder

    .loc    2 56
    lw  $3,Raziel+1436

    .loc    2 52
    li  $2,11           # 0x0000000b
    sh  $2,gameTrackerX+208

    .loc    2 53
    li  $2,-10          # 0xfffffff6
    sh  $2,gameTrackerX+204

    .loc    2 54
    li  $2,10           # 0x0000000a
    sh  $2,gameTrackerX+206

    .loc    2 56
    sltu    $3,$3,-23  # this should not need to load -23 into $at
    .set    noreorder
    .set    nomacro
    bne $3,$0,$L39
    move    $4,$17
mkst commented 6 months ago

Looks like we have code to cover this exact case.. so perhaps it's for an older version of aspsx?

        elif op == "sltu":
            r_dest, r_source, r_operand = rest[0].split(",")
            if re.match(r"^-?\d+$", r_operand) or re.match(
                r"^-?0x[A-Fa-f0-9]+$", r_operand
            ):
                value = int(r_operand)
                if value < 0:
                    res.append(f"li\t$at,{r_operand}")
                    res.append(f"{op}\t{r_dest},{r_source},$at")
                else:
                    res.append(line)
            else:
                res.append(line)