Switch To Next Thread
Jump to navigation
Jump to search
# ROUTINE: SWITCH TO NEXT THREAD # No parameters. 8014ca80: 3c018017 lui r1,0x8017 8014ca84: 00200821 addu r1,r1,r0 8014ca88: 8c284038 lw r8,0x4038(r1) # currentThreadID 8014ca8c: 00000000 nop 8014ca90: 00084280 sll r8,r8,0x0a # currentThreadID * sizeof(thread) 8014ca94: 3c018016 lui r1,0x8016 8014ca98: 00200821 addu r1,r1,r0 8014ca9c: 8c295f98 lw r9,0x5f98(r1) # Thread array base pointer 8014caa0: 00000000 nop 8014caa4: 01094021 addu r8,r8,r9 # threadPtr = (currentThreadID * sizeof(thread)) + (Thread array base pointer) 8014caa8: ad100010 sw r16,0x0010(r8) # Store "saved" register values to thread (including return address) 8014caac: ad110014 sw r17,0x0014(r8) 8014cab0: ad120018 sw r18,0x0018(r8) 8014cab4: ad13001c sw r19,0x001c(r8) 8014cab8: ad140020 sw r20,0x0020(r8) 8014cabc: ad150024 sw r21,0x0024(r8) 8014cac0: ad160028 sw r22,0x0028(r8) 8014cac4: ad17002c sw r23,0x002c(r8) 8014cac8: ad1a0030 sw r26,0x0030(r8) 8014cacc: ad1b0034 sw r27,0x0034(r8) 8014cad0: ad1c0038 sw r28,0x0038(r8) 8014cad4: ad1d003c sw r29,0x003c(r8) 8014cad8: ad1e0040 sw r30,0x0040(r8) 8014cadc: ad1f0044 sw r31,0x0044(r8) # while (true) { 8014cae0: 25080400 addiu r8,r8,0x0400 # threadPtr = threadPtr + sizeof(thread) 8014cae4: 3c018017 lui r1,0x8017 8014cae8: 00200821 addu r1,r1,r0 8014caec: 8c2a4038 lw r10,0x4038(r1) # currentThreadID 8014caf0: 00000000 nop 8014caf4: 254a0001 addiu r10,r10,0x0001 # currentThreadID + 1 8014caf8: 3c018017 lui r1,0x8017 8014cafc: 00200821 addu r1,r1,r0 8014cb00: ac2a4038 sw r10,0x4038(r1) # currentThreadID = currentThreadID + 1 8014cb04: 340b0010 ori r11,r0,0x0010 # 16 8014cb08: 114b0007 beq r10,r11,0x8014cb28 # if (currentThreadID == 16) // If above max, break 8014cb0c: 00000000 nop # break; 8014cb10: 8d0b0048 lw r11,0x0048(r8) # threadPtr.IsRunning 8014cb14: 00000000 nop 8014cb18: 140b0009 bne r0,r11,0x8014cb40 # if (threadPtr.IsRunning) break; 8014cb1c: 00000000 nop 8014cb20: 080532b8 j 0x8014cae0 # } 8014cb24: 00000000 nop # if (!threadPtr.IsRunning) { // If not running 8014cb28: 3c018016 lui r1,0x8016 8014cb2c: 00200821 addu r1,r1,r0 8014cb30: 8c285f98 lw r8,0x5f98(r1) # Thread array base pointer // Value never gets looked at. Loaded for no reason, it seems. \o/ 8014cb34: 3c018017 lui r1,0x8017 8014cb38: 00200821 addu r1,r1,r0 8014cb3c: ac204038 sw r0,0x4038(r1) # currentThreadID = 0 // No thread to switch to; Current Thread ID = 0 # } 8014cb40: 0c050b2a jal 0x80142ca8 # ROUTINE: ? 0x142ca8 (); 8014cb44: 00000000 nop 8014cb48: 3c018017 lui r1,0x8017 8014cb4c: 00200821 addu r1,r1,r0 8014cb50: 8c284038 lw r8,0x4038(r1) # currentThreadID 8014cb54: 00000000 nop 8014cb58: 00084280 sll r8,r8,0x0a # currentThreadID * sizeof(thread) 8014cb5c: 3c018016 lui r1,0x8016 8014cb60: 00200821 addu r1,r1,r0 8014cb64: 8c295f98 lw r9,0x5f98(r1) # Thread array base pointer 8014cb68: 00000000 nop 8014cb6c: 01094021 addu r8,r8,r9 # threadPtr = (currentThreadID * sizeof(thread)) + (Thread array base pointer) 8014cb70: 8d100010 lw r16,0x0010(r8) # Load "saved" register values from current thread (including return address) 8014cb74: 8d110014 lw r17,0x0014(r8) 8014cb78: 8d120018 lw r18,0x0018(r8) 8014cb7c: 8d13001c lw r19,0x001c(r8) 8014cb80: 8d140020 lw r20,0x0020(r8) 8014cb84: 8d150024 lw r21,0x0024(r8) 8014cb88: 8d160028 lw r22,0x0028(r8) 8014cb8c: 8d17002c lw r23,0x002c(r8) 8014cb90: 8d1a0030 lw r26,0x0030(r8) 8014cb94: 8d1b0034 lw r27,0x0034(r8) 8014cb98: 8d1c0038 lw r28,0x0038(r8) 8014cb9c: 8d1d003c lw r29,0x003c(r8) 8014cba0: 8d1e0040 lw r30,0x0040(r8) 8014cba4: 8d1f0044 lw r31,0x0044(r8) 8014cba8: 00000000 nop 8014cbac: 03e00008 jr r31 # Jump to return address for new current thread 8014cbb0: 00000000 nop