bits 32
section .text ;section declaration
global _start
_start:
mov edx, 9
jmp outerloop
outerloop:
mov ecx, 0 ; instead of 0, value should be the number of times outerloop has traversed
jmp innerloop
innerloop:
mov eax, [array + ecx * 4]
mov ebx, [array + 4 + ecx * 4]
cmp eax, ebx
jge next
mov [array + ecx * 4], ebx
mov [array + 4 + ecx * 4], eax
next:
inc ecx
cmp ecx, edx
jl innerloop
je endinner
endinner:
dec edx
jnz outerloop
done:
mov ebx,0 ;first syscall argument: exit code
mov eax,1 ;system call number (sys_exit)
int 0x80 ;"trap" to kernel
section .data ;section declaration
; This variable must remain named exactly 'array'
array dd 3, 9, 1, 6, 2, 4, 0, 5, 7, 8
section .bss
Yml0cyAzMgpzZWN0aW9uIC50ZXh0IDtzZWN0aW9uIGRlY2xhcmF0aW9uCmdsb2JhbCBfc3RhcnQKX3N0YXJ0OgogICAgbW92IGVkeCwgOQogICAgam1wIG91dGVybG9vcAoKb3V0ZXJsb29wOgogICAgbW92IGVjeCwgMCAgICAgICAgICA7IGluc3RlYWQgb2YgMCwgdmFsdWUgc2hvdWxkIGJlIHRoZSBudW1iZXIgb2YgdGltZXMgb3V0ZXJsb29wIGhhcyB0cmF2ZXJzZWQKICAgIGptcCBpbm5lcmxvb3AKCmlubmVybG9vcDoKICAgIG1vdiBlYXgsIFthcnJheSArIGVjeCAqIDRdCiAgICBtb3YgZWJ4LCBbYXJyYXkgKyA0ICsgZWN4ICogNF0KICAgIGNtcCBlYXgsIGVieAogICAgamdlIG5leHQKICAgIG1vdiBbYXJyYXkgKyBlY3ggKiA0XSwgZWJ4CiAgICBtb3YgW2FycmF5ICsgNCArIGVjeCAqIDRdLCBlYXgKbmV4dDoKICAgIGluYyBlY3gKICAgIGNtcCBlY3gsIGVkeAogICAgamwgaW5uZXJsb29wCiAgICBqZSBlbmRpbm5lcgplbmRpbm5lcjoKICAgIGRlYyBlZHgKICAgIGpueiBvdXRlcmxvb3AKZG9uZToKICAgIG1vdiBlYngsMCAgICAgICA7Zmlyc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