Advertisement
Cosmin3105

2

Nov 26th, 2021
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 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. formatScanf: .asciz "%[^\n]*400"
  10. printnr: .asciz "%d\n"
  11.  
  12. delim: .asciz " "
  13. .text
  14.  
  15. .global main
  16.  
  17. main:
  18. //scanf("[^\n]*400", &sir)
  19. pushl $sir
  20. pushl $formatScanf
  21. call scanf
  22. popl %ebx
  23. popl %ebx
  24.  
  25. //gets(sir)
  26. //pushl $sir
  27. //call gets
  28. //popl %ebx
  29.  
  30. push $delim
  31. pushl $sir
  32. call strtok
  33. popl %ebx
  34. popl %ebx
  35.  
  36. movl %eax, res
  37.  
  38. pushl res
  39. call atoi
  40. popl %ebx
  41.  
  42. movl %eax, atoiRes
  43.  
  44. pushl atoiRes
  45.  
  46. et_for:
  47. pushl $delim
  48. pushl $0
  49. call strtok
  50. popl %ebx
  51. popl %ebx
  52.  
  53. cmp $0, %eax
  54. je et_exit
  55.  
  56. movl %eax, res
  57.  
  58. pushl res
  59. call atoi
  60. popl %ebx
  61.  
  62. movl %eax, atoiRes
  63.  
  64. cmp $0, atoiRes
  65. je operatie
  66.  
  67. pushl atoiRes
  68. jmp et_for
  69.  
  70. operatie:
  71. movl res, %edi
  72. xorl %ecx, %ecx
  73. movb (%edi, %ecx, 1), %al
  74. cmp $97, %al
  75. je adunare
  76. cmp $115, %al
  77. je scadere
  78. cmp $109, %al
  79. je inmultire
  80. cmp $100, %al
  81. je impartire
  82.  
  83. adunare:
  84. popl op1
  85. popl %eax
  86. addl op1, %eax
  87. pushl %eax
  88. jmp et_for
  89.  
  90. scadere:
  91. popl op1
  92. popl %eax
  93. subl op1, %eax
  94. pushl %eax
  95. jmp et_for
  96.  
  97. inmultire:
  98. popl op1
  99. popl %eax
  100. mull op1
  101. pushl %eax
  102. jmp et_for
  103.  
  104. impartire:
  105. popl op1
  106. popl %eax
  107. xorl %edx, %edx
  108. divl op1
  109. pushl %eax
  110. jmp et_for
  111.  
  112. et_exit:
  113. pushl $printnr
  114. call printf
  115. popl %ebx
  116. popl %ebx
  117.  
  118. movl $1, %eax
  119. xorl %ebx, %ebx
  120. int $0x80
  121.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement