fork(2) download
  1. bits 32
  2. section .text ;section declaration
  3. global _start
  4. _start:
  5. mov edx, 9
  6. jmp outerloop
  7.  
  8. outerloop:
  9. mov ecx, 0 ; instead of 0, value should be the number of times outerloop has traversed
  10. jmp innerloop
  11.  
  12. innerloop:
  13. mov eax, [array + ecx * 4]
  14. mov ebx, [array + 4 + ecx * 4]
  15. cmp eax, ebx
  16. jge next
  17. mov [array + ecx * 4], ebx
  18. mov [array + 4 + ecx * 4], eax
  19. next:
  20. inc ecx
  21. cmp ecx, edx
  22. jl innerloop
  23. je endinner
  24. endinner:
  25. dec edx
  26. jnz outerloop
  27. done:
  28. mov ebx,0 ;first syscall argument: exit code
  29. mov eax,1 ;system call number (sys_exit)
  30. int 0x80 ;"trap" to kernel
  31.  
  32. section .data ;section declaration
  33. ; This variable must remain named exactly 'array'
  34. array dd 3, 9, 1, 6, 2, 4, 0, 5, 7, 8
  35.  
  36. section .bss
Success #stdin #stdout 0s 156KB
stdin
Standard input is empty
stdout
Standard output is empty