fork download
  1. ; Hello World in Assembly (Pure System Calls)
  2. section .data
  3. msg1 db 'Testing 1, 2, 3, 4', 0Ah, 0h ; original string
  4.  
  5. section .bss ;reserver buffer to store string
  6. reverse resb 256
  7.  
  8. section .text
  9. global _start
  10.  
  11. _start:
  12. mov eax, msg1
  13. call string_rev
  14. mov eax, reverse
  15.  
  16. call printLF
  17. call quit
  18.  
  19. string_rev:
  20. push ebx
  21. push ecx
  22. push edx
  23.  
  24. mov ebx, eax
  25. call string_len
  26. mov ecx, eax
  27.  
  28. mov esi, ebx
  29. mov edi, reverse
  30. add esi, ecx
  31. dec esi
  32.  
  33. rloop:
  34. cmp ecx, 0
  35. je reverse_done
  36.  
  37. mov al, [esi]
  38. mov [edi], al
  39. inc edi
  40. dec esi
  41. dec ecx
  42. jmp rloop
  43.  
  44. reverse_done:
  45. mov byte [edi], 0
  46. pop edx
  47. pop ecx
  48. pop ebx
  49. ret
  50.  
  51.  
  52.  
  53. string_len:
  54. push ebx
  55. mov ebx, eax
  56.  
  57. next_char:
  58. cmp byte [eax], 0
  59. jz slen_done
  60. inc eax
  61. jmp next_char
  62.  
  63. slen_done:
  64. sub eax, ebx
  65. pop ebx
  66. ret
  67.  
  68.  
  69.  
  70. printLF:
  71. call print
  72. push eax
  73. mov eax, 0Ah
  74. push eax
  75. mov eax, esp
  76. call print
  77. pop eax
  78. pop eax
  79. ret
  80.  
  81. print:
  82. push edx
  83. push ecx
  84. push ebx
  85. push eax
  86. call string_len
  87.  
  88. mov edx, eax
  89. pop eax
  90. mov ecx, eax
  91. mov ebx, 1
  92. mov eax, 4
  93. int 80h
  94.  
  95. pop ebx
  96. pop ecx
  97. pop edx
  98. ret
  99.  
  100. quit:
  101. mov ebx, 0
  102. mov eax, 1
  103. int 80h
  104. ret
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
4 ,3 ,2 ,1 gnitseT