fork download
  1. ;%include "io.mac"
  2. section .data
  3. hello db 'Hello World!'
  4.  
  5. section .text
  6. global _start
  7.  
  8. _start:
  9. ;GetLInt eax
  10. ;GetLInt ebx
  11. mov eax,10
  12. mov ebx,10
  13.  
  14. push eax
  15. push ebx
  16.  
  17. mov ebx,esp
  18. add ebx,4
  19. mov eax,esp
  20. add eax,8
  21. cmp dword [ebx],10
  22. je end
  23.  
  24. push ebx
  25. push eax
  26.  
  27. call multi
  28.  
  29. pop ebx
  30. pop ebx
  31.  
  32. ;PutLInt eax
  33. push eax
  34. mov eax,4
  35. mov ebx,1
  36. mov ecx,ebp
  37. mov edx,1
  38.  
  39. end: mov eax,1
  40. mov ebx,0
  41. int 80h;
  42.  
  43. %define a1 dword [ebp-8]
  44. %define a2 dword [ebp-12]
  45.  
  46. soma:enter 0,0
  47. mov eax,a1
  48. add eax,a2
  49. leave
  50. ret
  51.  
  52. %define mres dword[ebp+12]
  53. %define mcount dword[ebp+8]
  54. %define mbase dword[ebp+4]
  55.  
  56. multi:enter 12,0
  57.  
  58.  
  59. mov eax,a2
  60. mov mcount,eax ; Empilhando o contador utilizado nas multiplicações
  61. mov eax,ebp
  62. sub eax,8 ; eax = ebp - 8 (endereço de a1)
  63. mov mbase,eax ; Empilhando endereço da base
  64. mov eax,0
  65. mov mres,eax ; Empilhando total
  66.  
  67. loopmul:mov ecx,mcount
  68.  
  69. mov ecx,mcount
  70. cmp ecx,0
  71. jle retmult
  72.  
  73. sub ecx,1
  74.  
  75. mov mcount,ecx ; atualizando contador
  76. push mbase
  77. push mbase
  78.  
  79. ;call soma
  80.  
  81. pop ebx
  82. pop ebx ; Descartando os valores originais
  83. add eax,mres ; Somando ao resultado
  84. mov mres,eax
  85.  
  86. mov eax,4
  87. mov ebx,1
  88. mov ecx,hello
  89. mov edx,12
  90. int 80h
  91.  
  92. jmp loopmul
  93.  
  94. retmult: mov eax,4
  95. mov ebx,1
  96. mov ecx,hello
  97. mov edx,12
  98. int 80h
  99.  
  100. mov eax,mres
  101. leave
  102. ret
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty