fork download
  1.  
  2.  
  3. section .data
  4. prompt1 db "Key in the first number : ", 0
  5. prompt2 db "Key in the second number : ", 0
  6. result1 db "The total is ", 0
  7. result2 db "The division result is ", 0
  8. result3 db "The remainder value is ", 0
  9. newline db 10, 0
  10.  
  11. section .bss
  12. num1 resb 2
  13. num2 resb 2
  14.  
  15. section .text
  16. global _start
  17.  
  18. _start:
  19. ; Display prompt for first number
  20. mov eax, 4
  21. mov ebx, 1
  22. mov ecx, prompt1
  23. mov edx, 23
  24. int 0x80
  25.  
  26. ; Read first number
  27. mov eax, 3
  28. mov ebx, 0
  29. mov ecx, num1
  30. mov edx, 2
  31. int 0x80
  32.  
  33. ; Display prompt for second number
  34. mov eax, 4
  35. mov ebx, 1
  36. mov ecx, prompt2
  37. mov edx, 24
  38. int 0x80
  39.  
  40. ; Read second number
  41. mov eax, 3
  42. mov ebx, 0
  43. mov ecx, num2
  44. mov edx, 2
  45. int 0x80
  46.  
  47. ; Convert first number to integer
  48. mov al, [num1]
  49. sub al, '0'
  50. mov [num1], al
  51.  
  52. ; Convert second number to integer
  53. mov al, [num2]
  54. sub al, '0'
  55. mov [num2], al
  56.  
  57. ; Calculate multiplication
  58. mov al, [num1]
  59. mul byte [num2]
  60. mov [num1], al
  61.  
  62. ; Display multiplication result
  63. mov eax, 4
  64. mov ebx, 1
  65. mov ecx, result1
  66. mov edx, 13
  67. int 0x80
  68.  
  69. mov al, [num1]
  70. add al, '0'
  71. mov [num1], al
  72. mov ecx, num1
  73. mov edx, 1
  74. int 0x80
  75.  
  76. ; Display newline
  77. mov eax, 4
  78. mov ebx, 1
  79. mov ecx, newline
  80. mov edx, 1
  81. int 0x80
  82.  
  83. ; Calculate division
  84. mov al, [num1]
  85. div byte [num2]
  86. mov [num1], al
  87.  
  88. ; Display division result
  89. mov eax, 4
  90. mov ebx, 1
  91. mov ecx, result2
  92. mov edx, 16
  93. int 0x80
  94.  
  95. mov al, [num1]
  96. add al, '0'
  97. mov [num1], al
  98. mov ecx, num1
  99. mov edx, 1
  100. int 0x80
  101.  
  102. ; Display newline
  103. mov eax, 4
  104. mov ebx, 1
  105. mov ecx, newline
  106. mov edx, 1
  107. int 0x80
  108.  
  109. ; Calculate remainder
  110. mov al, [num1]
  111. mov ah, 0
  112. div byte [num2]
  113. mov [num1], ah
  114.  
  115. ; Display remainder
  116. mov eax, 4
  117. mov ebx, 1
  118. mov ecx, result3
  119. mov edx, 17
  120. int 0x80
  121.  
  122. mov al, [num1]
  123. add al, '0'
  124. mov [num1], al
  125. mov ecx, num1
  126. mov edx, 1
  127. int 0x80
  128.  
  129. ; Display newline
  130. mov eax, 4
  131. mov ebx, 1
  132. mov ecx, newline
  133. mov edx, 1
  134. int 0x80
  135.  
  136. ; Exit program
  137. mov eax, 1
  138. xor ebx, ebx
  139. int 0x80
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
Key in the first numberKey in the second numberThe total is 
The division res
The remainder val