Advertisement
MadCortez

Untitled

Mar 29th, 2021
2,116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 100h
  2.  
  3. mov ah, 9h
  4. mov dx, task1
  5. int 21h
  6.  
  7. mov ah,9h
  8. mov dx, task2
  9. int 21h
  10.  
  11. mov ah, 09h
  12. mov dx, inputA
  13. int 21h
  14.  
  15. mov ah, 0ah
  16. mov dx, strA
  17. int 21h
  18.  
  19. mov bx, dx
  20. call get_number
  21. push ax
  22.  
  23. mov ah, 02h
  24. mov dx, 0x0D0A
  25. int 21h
  26.  
  27. mov ah, 09h
  28. mov dx, inputB
  29. int 21h
  30.  
  31. mov ah, 0ah
  32. mov dx, strB
  33. int 21h
  34.  
  35. mov bx, dx
  36. call get_number
  37. push ax
  38.  
  39. call get_result
  40. mov ax, [res]
  41. call output_number
  42.  
  43. pop ax
  44. pop ax
  45.  
  46. mov ah, 8h
  47. int 21h
  48.  
  49. ret
  50.  
  51. get_result:
  52.  
  53. mov bp, sp
  54. mov ax, [bp+4]
  55. mov bx, [bp+2]
  56. mov [A], ax
  57. mov [B], bx
  58. mov si, bx
  59.  
  60. mov cx, 3h
  61. dec cx
  62. loopA: mul [A]
  63. loop loopA
  64. mov bx, ax
  65.  
  66. mov ax, si
  67. mov cx, 2h
  68. dec cx
  69. loopB: mul [B]
  70. loop loopB
  71. sub bx, ax
  72.  
  73. mov [res], bx
  74.  
  75. ret
  76.  
  77. get_number:
  78.  
  79. xor ax, ax
  80. xor dx, dx
  81. add bx, 1h
  82. mov cl, [bx]
  83.  
  84. lp:
  85.  
  86. inc bx
  87. mul [cm]
  88. add al, [bx]
  89. sub ax, '0'
  90.  
  91. loop lp
  92.  
  93. ret
  94.  
  95. output_number:
  96.  
  97. push '*'
  98.  
  99. lpt:
  100.  
  101. div [cm]
  102. push dx
  103. xor dx, dx
  104. cmp ax, 0h
  105. jne lpt
  106.  
  107. mov ah, 02h
  108. mov dx, 0x0D0A
  109. int 21h
  110.  
  111. lpp:
  112.  
  113. pop bx
  114. cmp bx, '*'
  115. je endst
  116. add bx, '0'
  117.  
  118. mov ah, 02h
  119. mov dx, bx
  120. int 21h
  121.  
  122. jmp lpp
  123.  
  124. endst: ret
  125.  
  126. cm dw 10
  127. inputA db "Enter number A: $"
  128. inputB db "Enter number B: $"
  129. task1 db "This program calculates A^3 - B^2",$0d,$0a, "$"
  130. task2 db "Using stack", $0d, $0a, "$"
  131. new_line db $0d, $0A, "$"
  132. strA db 10, 0, 10 dup(?)
  133. strB db 10, 0, 10 dup(?)
  134. A dw 0h
  135. B dw 0h
  136. res dw 0h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement