Skip to content

COP0.Count assumed 0 #98

@google0101-ryan

Description

@google0101-ryan

I'm trying to RE the PS2's BIOS, and I've encountered a strange bug where large portions of code is optimized out of the decompilation view. These chunks of code all seem to be code that involves polling COP0.count, which Ghidra seems to assume is always zero. Is there a fix for this?

Example below

ASM:

                             *                          FUNCTION                          *
                             **************************************************************
                             undefined FUN_9fc42910()
                               assume gp = 0x0
             undefined         <UNASSIGNED>   <RETURN>
                             FUN_9fc42910                                    XREF[3]:     InitRDRAM:9fc41368(c), 
                                                                                          InitRDRAM:9fc41a7c(c), 
                                                                                          InitRDRAM:9fc41f38(c)  
        9fc42910 f4 01 02 24     li         v0,0x1f4
             assume gp = <UNKNOWN>
        9fc42914 1b 00 a2 00     divu       a1,v0
        9fc42918 01 00 40 50     beql       v0,zero,LAB_9fc42920
        9fc4291c cd 01 00 00     _break     0x7
                             LAB_9fc42920                                    XREF[1]:     9fc42918(j)  
        9fc42920 12 28 00 00     mflo       a1
        9fc42924 18 20 85 00     mult       a0,a0,a1
        9fc42928 00 48 03 40     mfc0       v1,Count
        9fc4292c 00 00 00 00     nop
                             LAB_9fc42930                                    XREF[1]:     9fc42944(j)  
        9fc42930 00 48 02 40     mfc0       v0,Count
        9fc42934 23 10 43 00     subu       v0,v0,v1
        9fc42938 2b 10 44 00     sltu       v0,v0,a0
        9fc4293c 00 00 00 00     nop
        9fc42940 00 00 00 00     nop
        9fc42944 fa ff 40 14     bne        v0,zero,LAB_9fc42930
        9fc42948 00 00 00 00     _nop
        9fc4294c 08 00 e0 03     jr         ra
        9fc42950 00 00 00 00     _nop

C:

void FUN_9fc42910(int param_1,int param_2)

{
  do {
  } while (param_1 * (param_2 / 500) != 0);
  return;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions