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