Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .386
  2. .model large
  3. .stack 100h
  4. .data
  5.  
  6. old dw 0h, 0h ;dw - 2 ????? ??? ??????????
  7.  
  8. etr dw 0Ah, 0Dh ;???? ?????????? ? ??????? ??????????
  9.  
  10. message db 'AX: $'
  11.  
  12.            
  13. .code
  14.  
  15. start:
  16.  
  17. ;??????? ?? ??????
  18.  
  19. jmp beg ;??????????? ???????
  20.  
  21. print_symbol:
  22.  
  23. ;??????????? ??????
  24.  
  25. push ax
  26.  
  27. push dx
  28.  
  29. mov ah, 02h ;????? ?? ???????
  30.  
  31. mov dl, dh ;dl - ?????? ?????????
  32.  
  33. cmp dl, 0 ;c????????? ? ?????
  34.  
  35. je t2 ;???????? ???????, ???? ZF=1; ??????? ???? ???? ??? ?????
  36.  
  37. int 21h
  38.  
  39. t2:
  40.  
  41. pop dx
  42.  
  43. int 21h
  44.  
  45. pop ax
  46.  
  47. ret ; ?????? ????????? ?????? ?? ?????, ????? ??????? ????
  48.  
  49. print_number:
  50.  
  51. ;??????????? ?????, base = 10
  52.  
  53. push ax
  54.  
  55. push bx
  56.  
  57. push cx
  58.  
  59. push dx
  60.  
  61. mov ax, dx
  62.  
  63. mov bx, 10
  64.  
  65. mov cx, 0
  66.  
  67. getdigits:
  68.  
  69. mov dx, 0
  70.  
  71. div bx
  72.  
  73. inc cx
  74.  
  75. add dx,
  76.  
  77. push dx
  78.  
  79. cmp ax, 0
  80.  
  81. jnz getdigits
  82.  
  83. mov ah, 02h
  84.  
  85. printdigits:
  86.  
  87. pop dx
  88.  
  89. int 21h
  90.  
  91. loop printdigits
  92.  
  93. pop dx
  94.  
  95. pop cx
  96.  
  97. pop bx
  98.  
  99. pop ax
  100.  
  101. ret
  102.  
  103. debug:
  104.  
  105. ;????????? ????????, ????????? ??????????
  106.  
  107. cli ;Clear Interrupt-Enable Flag IF
  108.  
  109. push bp
  110.  
  111. mov bp, sp
  112.  
  113. push ax
  114.  
  115. push bx
  116.  
  117. push cx
  118.  
  119. push dx
  120.  
  121. push si
  122.  
  123. ;????? ax
  124.  
  125. mov ah,09h
  126.  
  127. lea dx,message
  128.  
  129. int 21h
  130.  
  131. mov dx, [bp-2]
  132.  
  133. call print_number
  134.  
  135. mov dx, etr
  136.  
  137. call print_symbol
  138.  
  139. ;??????? ??????? ???????
  140.  
  141. xor ax, ax
  142.  
  143. int 16h
  144.  
  145. ;???????? ??????
  146.  
  147. mov ah, 02h
  148.  
  149. mov dl, 07h ; ASCII ??? ??????? BELL
  150.  
  151. int 21h ; ??????? ?????
  152.  
  153. pop si
  154.  
  155. pop dx
  156.  
  157. pop cx
  158.  
  159. pop bx
  160.  
  161. pop ax
  162.  
  163. pop bp
  164.  
  165. sti
  166.  
  167. iret
  168.  
  169. ;???????????? ?????????
  170.  
  171. thread:
  172.  
  173. mov ax, 1
  174.  
  175. mov cx, 10
  176.  
  177. t1:
  178.  
  179. add ax, ax
  180.  
  181. loop t1
  182.  
  183. ret
  184.  
  185. beg:
  186.  
  187. ;????????? ?????? ??????????
  188.  
  189. mov ax, 3501h ; 01h - ???? ? ??????????
  190.  
  191. int 21h
  192.  
  193. mov old, bx
  194.  
  195. mov old+2, es
  196.  
  197. ;?????????? ????? ??????????
  198.  
  199. push cs ;??????? ????(???????? ??????) ??????????? ? ?????? ?????? ?????????
  200.  
  201. pop ds
  202.  
  203. mov dx, offset debug ;????? ????? ????? ??????
  204.  
  205. mov ax, 2501h
  206.  
  207. int 21h ;??????????? ?????????? DOS ????????? ?? ???????? ah
  208.  
  209. ;????????? ???????? ??? ????????
  210.  
  211. pushf
  212.  
  213. push offset exit
  214.  
  215. ;????????? TF ????, ?? ????????? ????????? ???????, ????? ????? ??????
  216.  
  217. ; ?????????? ?????????? ?????????? ????????? ? ????? ???????????? ???????????
  218.  
  219. pushf
  220.  
  221. pop ax
  222.  
  223. or ax, 0100h ;TF ???? ???????????????
  224.  
  225. push ax
  226.  
  227. push cs ;???????? ???????? ????
  228.  
  229. push offset thread ;???????????? ????? ?? ??? ???????
  230.  
  231. iret ;????????? ?? ????? ????? ???????? ip(thread) ????? cs ?????
  232.  
  233. ;???? ??????????? ???????? ????????? ?????? ??????? ?? ? ax ????????
  234.  
  235. exit:
  236.  
  237. popf ; ??????????????? ???????? ???????? ??????
  238.  
  239. ;?????????? ?????? ??????????
  240.  
  241. lea dx, old
  242.  
  243. mov ax, 2501h
  244.  
  245. int 21h
  246.  
  247. ;????? ????? ??????? ???????
  248.  
  249. mov ax, 4c00h
  250.  
  251. int 21h
  252.  
  253. int 20h
  254.  
  255.  
  256.  
  257.  
  258. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement