Advertisement
Cosmin3105

3

Nov 26th, 2021
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. .data
  2. sir: .space 400
  3.  
  4. res: .space 4
  5. atoiRes: .space 4
  6.  
  7. op1: .space 4
  8.  
  9. variabile: .space 200
  10.  
  11. nume_var: .space 4
  12. valoare: .space 4
  13.  
  14. formatScanf: .asciz "%[^\n]*400"
  15. printnr: .asciz "%d\n"
  16.  
  17. delim: .asciz " "
  18. .text
  19.  
  20. .global main
  21.  
  22. main:
  23. movl $variabile, %edi
  24. xorl %ecx, %ecx
  25. init:
  26. cmp $26, %ecx
  27. je incepe
  28.  
  29. movl $-1, %eax
  30. movl %eax, (%edi, %ecx, 4)
  31. incl %ecx
  32. jmp init
  33.  
  34. incepe:
  35. //scanf("%[^\n]*400", sir)
  36. pushl $sir
  37. pushl $formatScanf
  38. call scanf
  39. popl %ebx
  40. popl %ebx
  41.  
  42. //strtok(sir, " ")
  43. pushl $delim
  44. pushl $sir
  45. call strtok
  46. popl %ebx
  47. popl %ebx
  48.  
  49. movl %eax, res
  50.  
  51. pushl res
  52. call atoi
  53. popl %ebx
  54.  
  55. movl %eax, atoiRes
  56.  
  57. cmp $0, atoiRes
  58. je var1
  59.  
  60. pushl atoiRes
  61. jmp et_for
  62.  
  63. var1:
  64. pushl res
  65.  
  66. et_for:
  67. pushl $delim
  68. pushl $0
  69. call strtok
  70. popl %ebx
  71. popl %ebx
  72.  
  73. movl %eax, res
  74. cmp $0, res
  75. je et_exit
  76.  
  77. pushl res
  78. call atoi
  79. popl %ebx
  80.  
  81. movl %eax, atoiRes
  82.  
  83. cmp $0, atoiRes
  84. je operatie_sau_var
  85.  
  86. pushl atoiRes
  87.  
  88. jmp et_for
  89.  
  90. operatie_sau_var:
  91. movl res, %edi
  92.  
  93. xorl %eax, %eax
  94. xorl %ebx, %ebx
  95. xorl %ecx, %ecx
  96.  
  97. movb (%edi, %ecx, 1), %al
  98. incl %ecx
  99. movb (%edi, %ecx, 1), %ah
  100.  
  101. cmpb $0, %ah
  102. jne operatie
  103.  
  104. verif_exist:
  105. movl $variabile, %edi
  106. subl $97, %eax
  107. movl %eax, %ecx
  108. movl (%edi, %ecx, 4), %ebx
  109. cmp $-1, %ebx
  110. jne var_exista
  111.  
  112. cont2:
  113. pushl res
  114.  
  115. jmp et_for
  116.  
  117. var_exista:
  118. movl (%edi, %ecx, 4), %eax
  119. pushl %eax
  120.  
  121. jmp et_for
  122.  
  123. operatie:
  124. cmp $97, %al
  125. je adunare
  126. cmp $115, %al
  127. je scadere
  128. cmp $109, %al
  129. je inmultire
  130. cmp $100, %al
  131. je impartire
  132. cmp $108, %al
  133. je atribuire
  134.  
  135. adunare:
  136. popl op1
  137. popl %eax
  138. addl op1, %eax
  139. pushl %eax
  140. jmp et_for
  141.  
  142. scadere:
  143. popl op1
  144. popl %eax
  145. subl op1, %eax
  146. pushl %eax
  147. jmp et_for
  148.  
  149. inmultire:
  150. popl op1
  151. popl %eax
  152. mull op1
  153. pushl %eax
  154. jmp et_for
  155.  
  156. impartire:
  157. popl op1
  158. popl %eax
  159. xorl %edx, %edx
  160. divl op1
  161. pushl %eax
  162. jmp et_for
  163.  
  164. atribuire:
  165. movl $variabile, %edi
  166.  
  167. popl valoare
  168. popl nume_var
  169.  
  170. movl nume_var, %esi
  171. xorl %ecx, %ecx
  172. xorl %eax, %eax
  173. movb (%esi, %ecx, 1), %al
  174.  
  175. subl $97, %eax
  176. movl %eax, %ecx
  177.  
  178. movl valoare, %eax
  179. movl %eax, (%edi, %ecx, 4)
  180.  
  181. jmp et_for
  182.  
  183. et_exit:
  184. pushl $printnr
  185. call printf
  186. popl %ebx
  187. popl %ebx
  188.  
  189. movl $1, %eax
  190. xorl %ebx, %ebx
  191. int $0x80
  192.  
  193.  
  194.  
  195.  
  196.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement