How Selection Sort Works: A Simple Example
Click 'Next' to start the tutorial.
Assembly Implementation: Byte-Sorting Program
Enter characters and press "Sort" to begin.
Live Execution Details
Conceptual Assembly CodePseudo Machine Code
; R1 -> unsorted_end_ptr, R2 -> current_item_ptr
; R3 -> max_ptr, R4 -> max_val, R5 -> temp
OUTER_LOOP:
0x1000 Move (LIST), R4
0x1004 Move #LIST, R3
0x1008 Move #LIST+1, R2
INNER_LOOP:
0x100C Compare (R2), R4
0x1010 Branch<=0 SKIP
0x1014 Move (R2), R4
0x1018 Move R2, R3
SKIP:
0x101C Add #1, R2
0x1020 Compare R2, R1
0x1024 Branch<=0 INNER_LOOP
SWAP:
0x1028 Move (R1), R5
0x102C Move (R3), (R1)
0x1030 Move R5, (R3)
0x1034 Decrement R1
0x1038 Compare R1, #LIST
0x103C Branch>0 OUTER_LOOP
DONE:
Memory State: LIST
Register States
R1: null
R2: null
R3: null
R4: null
R5: null
Explanation
Enter characters and press "Sort" to begin the assembly visualization.