Boollik

Untitled

Jan 17th, 2023
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. .model small
  2. data segment
  3. msg_a db 13,10, "a = ", '$'
  4. msg_b db 13,10, "b = ", '$'
  5. msg_c db 13,10, "c = ", '$'
  6. msg_d db 13,10, "d = ", '$'
  7. msg_result db 13,10, "a*c*(a+b)-d = ", '$'
  8. a db ?
  9. b db ?
  10. c db ?
  11. d dw ?
  12. result dw ?
  13. data ends
  14. stk segment stack
  15. db 256 dup(?)
  16. stk ends
  17. code segment
  18. assume cs: code, ds: data, ss: stk
  19. start:
  20. mov ax, data
  21. mov ds, ax
  22. Vvod_peremenou:
  23. mov ah, 09h
  24. lea dx, [msg_d]
  25. int 21h
  26. mov di, offset store_D
  27. jmp ReadInt16
  28. store_D:
  29.  
  30.  
  31. mov [d], ax
  32. mov ah, 09h
  33. lea dx, [msg_a]
  34. int 21h
  35. mov di, offset store_A
  36. jmp ReadInt16
  37. store_A:
  38. mov [a], al
  39.  
  40. mov ah, 09h
  41. lea dx, [msg_b]
  42. int 21h
  43. mov di, offset store_B
  44. jmp ReadInt16
  45. store_B:
  46. mov [b], al
  47.  
  48. mov ah, 09h
  49. lea dx, [msg_c]
  50. int 21h
  51. mov di, offset store_C
  52. jmp ReadInt16
  53. store_C:
  54. mov [c], al
  55.  
  56.  
  57. Vichislenia:
  58. mov al,[a]
  59. imul [c]
  60. mov bx, ax
  61. mov al,[a]
  62. add al,[b]
  63. cbw
  64. imul bx
  65. sub ax,[d]
  66. mov [result], ax
  67. Vivod_resultata:
  68. mov ah, 09h
  69. lea dx, [msg_result]
  70. int 21h
  71. mov ax, [result]
  72.  
  73. Vivod_result:
  74. mov bx, 10
  75. xor cx, cx
  76. or ax, ax
  77. jns _div
  78. neg ax
  79. push ax
  80. mov ah, 02h
  81. mov dl, '-'
  82. int 21h
  83. pop ax
  84. _div:
  85. xor dx, dx
  86. div bx
  87. push dx
  88. inc cx
  89. or ax, ax
  90. jnz _div
  91. mov ah, 02h
  92. store:
  93. pop dx
  94. add dl, '0'
  95. int 21h
  96. loop store
  97. ReadInt16:
  98. xor bx, bx
  99. xor cx, cx
  100. do:
  101. mov ah, 00h
  102. int 16h
  103.  
  104.  
  105. mov dl, al
  106. cmp al, 0Dh
  107. je _break
  108. cmp al, '-'
  109. jne plyc
  110. mov bx, 1
  111. cmp bx,1
  112. je putchar
  113. plyc:
  114. cmp al,'+'
  115. jne @endif
  116. mov bx,0
  117. je putchar
  118. @endif:
  119. sub al, '0'
  120. jc do
  121. cmp al, 9+1
  122. jnc do
  123.  
  124.  
  125. xor ah, ah
  126. shl cx, 1
  127. mov si, cx
  128. shl cx, 1
  129. shl cx, 1
  130. add cx, si
  131. add cx, ax
  132.  
  133. putchar:
  134.  
  135. mov ah, 02h
  136. int 21h
  137.  
  138. jmp do
  139. _break:
  140. mov ax, cx
  141. test bx, bx
  142. jz exit
  143. neg ax
  144. exit:
  145. jmp di
  146. the_end:
  147. mov ax, 4C00h
  148. code ends
  149. end start
Advertisement
Add Comment
Please, Sign In to add comment