fork download
  1. section .data
  2. a db 9
  3. b db 3
  4.  
  5. msg1 db "9 + 3 = "
  6. len1 equ $-msg1
  7.  
  8. msg2 db 10,"9 - 3 = "
  9. len2 equ $-msg2
  10.  
  11. msg3 db 10,"9 * 3 = "
  12. len3 equ $-msg3
  13.  
  14. msg4 db 10,"9 / 3 = "
  15. len4 equ $-msg4
  16.  
  17. section .bss
  18. result resb 2
  19.  
  20. section .text
  21. global _start
  22.  
  23. _start:
  24.  
  25. ;=========================
  26. ; Tong
  27. ;=========================
  28. mov eax,4
  29. mov ebx,1
  30. mov ecx,msg1
  31. mov edx,len1
  32. int 0x80
  33.  
  34. mov al,[a]
  35. add al,[b] ; 12
  36.  
  37. aam ; AH=1 AL=2
  38. add ax,3030h
  39.  
  40. mov [result],ah
  41. mov [result+1],al
  42.  
  43. mov eax,4
  44. mov ebx,1
  45. mov ecx,result
  46. mov edx,2
  47. int 0x80
  48.  
  49. ;=========================
  50. ; Hieu
  51. ;=========================
  52. mov eax,4
  53. mov ebx,1
  54. mov ecx,msg2
  55. mov edx,len2
  56. int 0x80
  57.  
  58. mov al,[a]
  59. sub al,[b]
  60. add al,'0'
  61.  
  62. mov [result],al
  63.  
  64. mov eax,4
  65. mov ebx,1
  66. mov ecx,result
  67. mov edx,1
  68. int 0x80
  69.  
  70. ;=========================
  71. ; Tich
  72. ;=========================
  73. mov eax,4
  74. mov ebx,1
  75. mov ecx,msg3
  76. mov edx,len3
  77. int 0x80
  78.  
  79. mov al,[a]
  80. mul byte [b] ; 27
  81.  
  82. aam
  83. add ax,3030h
  84.  
  85. mov [result],ah
  86. mov [result+1],al
  87.  
  88. mov eax,4
  89. mov ebx,1
  90. mov ecx,result
  91. mov edx,2
  92. int 0x80
  93.  
  94. ;=========================
  95. ; Thuong
  96. ;=========================
  97. mov eax,4
  98. mov ebx,1
  99. mov ecx,msg4
  100. mov edx,len4
  101. int 0x80
  102.  
  103. xor ah,ah
  104. mov al,[a]
  105. div byte [b]
  106.  
  107. add al,'0'
  108. mov [result],al
  109.  
  110. mov eax,4
  111. mov ebx,1
  112. mov ecx,result
  113. mov edx,1
  114. int 0x80
  115.  
  116. ;=========================
  117. ; Xuống dòng cuối
  118. ;=========================
  119. mov eax,4
  120. mov ebx,1
  121. mov ecx,newline
  122. mov edx,1
  123. int 0x80
  124.  
  125. mov eax,1
  126. xor ebx,ebx
  127. int 0x80
  128.  
  129. section .data
  130. newline db 10
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
9 + 3 = 12
9 - 3 = 6
9 * 3 = 27
9 / 3 = 3