Switch To Next Thread (WORLD.BIN)
Revision as of 01:52, 18 May 2018 by Glain (talk | contribs) (Created page with " # ROUTINE: SWITCH TO NEXT THREAD (WORLD.BIN) # This routine is an analog to Switch To Next Thread in BATTLE.BIN. # No parameters. 800fff50: 3c01801d lui r1,0x8...")
# ROUTINE: SWITCH TO NEXT THREAD (WORLD.BIN) # This routine is an analog to Switch To Next Thread in BATTLE.BIN. # No parameters. 800fff50: 3c01801d lui r1,0x801d 800fff54: 00200821 addu r1,r1,r0 800fff58: 8c28d170 lw r8,-0x2e90(r1) # currentThreadID (*0x801cd170) 800fff5c: 00000000 nop 800fff60: 00084280 sll r8,r8,0x0a # currentThreadID * sizeof(thread) 800fff64: 3c018015 lui r1,0x8015 800fff68: 00200821 addu r1,r1,r0 800fff6c: 8c29327c lw r9,0x327c(r1) # Thread array base pointer (*0x8015327c) 800fff70: 00000000 nop 800fff74: 01094021 addu r8,r8,r9 # threadPtr = (currentThreadID * sizeof(thread)) + (Thread array base pointer) 800fff78: ad100010 sw r16,0x0010(r8) # Store "saved" register values to thread (including return address) 800fff7c: ad110014 sw r17,0x0014(r8) 800fff80: ad120018 sw r18,0x0018(r8) 800fff84: ad13001c sw r19,0x001c(r8) 800fff88: ad140020 sw r20,0x0020(r8) 800fff8c: ad150024 sw r21,0x0024(r8) 800fff90: ad160028 sw r22,0x0028(r8) 800fff94: ad17002c sw r23,0x002c(r8) 800fff98: ad1a0030 sw r26,0x0030(r8) 800fff9c: ad1b0034 sw r27,0x0034(r8) 800fffa0: ad1c0038 sw r28,0x0038(r8) 800fffa4: ad1d003c sw r29,0x003c(r8) 800fffa8: ad1e0040 sw r30,0x0040(r8) 800fffac: ad1f0044 sw r31,0x0044(r8) # while (true) { 800fffb0: 25080400 addiu r8,r8,0x0400 # threadPtr = threadPtr + sizeof(thread) 800fffb4: 3c01801d lui r1,0x801d 800fffb8: 00200821 addu r1,r1,r0 800fffbc: 8c2ad170 lw r10,-0x2e90(r1) # currentThreadID 800fffc0: 00000000 nop 800fffc4: 254a0001 addiu r10,r10,0x0001 # currentThreadID + 1 800fffc8: 3c01801d lui r1,0x801d 800fffcc: 00200821 addu r1,r1,r0 800fffd0: ac2ad170 sw r10,-0x2e90(r1) # currentThreadID = currentThreadID + 1 800fffd4: 340b0011 ori r11,r0,0x0011 # 17 800fffd8: 114b0007 beq r10,r11,0x800ffff8 # if (currentThreadID == 17) // If above max, break 800fffdc: 00000000 nop # break; 800fffe0: 8d0b0048 lw r11,0x0048(r8) # threadPtr.IsRunning 800fffe4: 00000000 nop 800fffe8: 140b0009 bne r0,r11,0x80100010 # if (threadPtr.IsRunning) break; 800fffec: 00000000 nop 800ffff0: 0803ffec j 0x800fffb0 # } 800ffff4: 00000000 nop # if (!threadPtr.IsRunning) { // If not running 800ffff8: 3c018015 lui r1,0x8015 800ffffc: 00200821 addu r1,r1,r0 80100000: 8c28327c lw r8,0x327c(r1) # Thread array base pointer // Value never gets looked at. Loaded for no reason, it seems. \o/ 80100004: 3c01801d lui r1,0x801d 80100008: 00200821 addu r1,r1,r0 8010000c: ac20d170 sw r0,-0x2e90(r1) # currentThreadID = 0 // No thread to switch to; Current Thread ID = 0 # } 80100010: 0c03d95a jal 0x800f6568 # ROUTINE: ? 0xf6568 (); 80100014: 00000000 nop 80100018: 3c01801d lui r1,0x801d 8010001c: 00200821 addu r1,r1,r0 80100020: 8c28d170 lw r8,-0x2e90(r1) # currentThreadID 80100024: 00000000 nop 80100028: 00084280 sll r8,r8,0x0a # currentThreadID * sizeof(thread) 8010002c: 3c018015 lui r1,0x8015 80100030: 00200821 addu r1,r1,r0 80100034: 8c29327c lw r9,0x327c(r1) # Thread array base pointer 80100038: 00000000 nop 8010003c: 01094021 addu r8,r8,r9 # threadPtr = (currentThreadID * sizeof(thread)) + (Thread array base pointer) 80100040: 8d100010 lw r16,0x0010(r8) # Load "saved" register values from current thread (including return address) 80100044: 8d110014 lw r17,0x0014(r8) 80100048: 8d120018 lw r18,0x0018(r8) 8010004c: 8d13001c lw r19,0x001c(r8) 80100050: 8d140020 lw r20,0x0020(r8) 80100054: 8d150024 lw r21,0x0024(r8) 80100058: 8d160028 lw r22,0x0028(r8) 8010005c: 8d17002c lw r23,0x002c(r8) 80100060: 8d1a0030 lw r26,0x0030(r8) 80100064: 8d1b0034 lw r27,0x0034(r8) 80100068: 8d1c0038 lw r28,0x0038(r8) 8010006c: 8d1d003c lw r29,0x003c(r8) 80100070: 8d1e0040 lw r30,0x0040(r8) 80100074: 8d1f0044 lw r31,0x0044(r8) 80100078: 00000000 nop 8010007c: 03e00008 jr r31 # Jump to return address for new current thread 80100080: 00000000 nop