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