Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sort3Numbers: ;provide s0 (where to read numbers from)
- ADDIU sp, sp, -0x30
- SW t0, 0x0010 (sp)
- SW t1, 0x0014 (sp)
- SW t2, 0x0018 (sp)
- SW v0, 0x001C (sp)
- SW s0, 0x0020 (sp)
- SW ra, 0x0024 (sp)
- ;LUI s0, hi(ItemIDsChosen)
- ;ADDIU s0, s0, lo(ItemIDsChosen)
- LB t0, 0x0000 (s0) ;load item a
- LB t1, 0x0001 (s0) ;load item b
- LB t2, 0x0002 (s0) ;load item c
- SLT v0, t2, t0 ;if c is less than a, v0 = 1
- BNE v0, r0, swapCandA
- NOP
- afterCandA:
- LB t0, 0x0000 (s0)
- LB t1, 0x0001 (s0)
- LB t2, 0x0002 (s0)
- SLT v0, t1, t0, ;if b is less than a
- BNE v0, r0, swapAandB
- NOP
- afterAandB:
- LB t0, 0x0000 (s0)
- LB t1, 0x0001 (s0)
- LB t2, 0x0002 (s0)
- SLT v0, t2, t1 ;if c is less than b
- BNE v0, r0, swapBandC
- NOP
- afterBandC:
- LW t0, 0x0010 (sp)
- LW t1, 0x0014 (sp)
- LW t2, 0x0018 (sp)
- LW v0, 0x001C (sp)
- LW s0, 0x0020 (sp)
- LW ra, 0x0024 (sp)
- JR RA
- ADDIU sp, sp, 0x30
- swapCandA:
- SB t0, 0x0002 (s0)
- BEQ r0, r0, afterCandA
- SB t2, 0x0000 (s0)
- swapAandB:
- SB t0, 0x0001 (s0)
- BEQ r0, r0, afterAandB
- SB t1, 0x0000 (s0)
- swapBandC:
- SB t1, 0x0002 (s0)
- BEQ r0, r0, afterBandC
- SB t2, 0x0001 (s0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement