Advertisement
MadCortez

Untitled

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