Advertisement
MadCortez

Untitled

Mar 29th, 2021
2,073
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. mov [A], 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. mov [B], ax
  38.  
  39. call get_result
  40. mov ax, [res]
  41. call output_number
  42.  
  43. mov ah, 8h
  44. int 21h
  45.  
  46. ret
  47.  
  48. get_result:
  49.  
  50. mov ax, [A]
  51. mov bx, [B]
  52. mov si, bx
  53. mov cx, 3h
  54. dec cx
  55. loopA: mul [A]
  56. loop loopA
  57. mov bx, ax
  58. mov ax, si
  59. mov cx, 2h
  60. dec cx
  61. loopB: mul [B]
  62. loop loopB
  63. sub bx, ax
  64.  
  65. mov [res], bx
  66.  
  67. ret
  68.  
  69. get_number:
  70.  
  71. xor ax, ax
  72. xor dx, dx
  73. add bx, 1h
  74. mov cl, [bx]
  75.  
  76. lp:
  77.  
  78. inc bx
  79. mul [cm]
  80. add al, [bx]
  81. sub ax, '0'
  82. loop lp
  83.  
  84. ret
  85.  
  86. output_number:
  87.  
  88. push '*'
  89.  
  90. lpt:
  91.  
  92. div [cm]
  93. push dx
  94. xor dx, dx
  95. cmp ax, 0h
  96. jne lpt
  97.  
  98. mov ah, 02h
  99. mov dx, 0x0D0A
  100. int 21h
  101.  
  102. lpp:
  103.  
  104. pop bx
  105. cmp bx, '*'
  106. je endst
  107. add bx, '0'
  108.  
  109. mov ah, 02h
  110. mov dx, bx
  111. int 21h
  112.  
  113. jmp lpp
  114.  
  115. endst: ret
  116.  
  117. cm dw 10
  118. inputA db "Enter number A: $"
  119. inputB db "Enter number B: $"
  120. task1 db "This program calculates A^3 - B^2",$0d,$0a, "$"
  121. task2 db "Using global variables", $0d, $0a, "$"
  122. new_line db $0d, $0A, "$"
  123. strA db 10, 0, 10 dup(?)
  124. strB db 10, 0, 10 dup(?)
  125. A dw 0h
  126. B dw 0h
  127. res dw 0h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement