Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. .model tiny
  2. .code
  3. org 100h
  4. jmp start
  5. start_resident:
  6. new_int9 proc far ;must be far + iret
  7. pushf
  8. call cs:old_int9
  9. pusha
  10. push ds
  11. push es
  12. push cs
  13. pop ds
  14. mov ax, 0b800h
  15. mov es, ax
  16. cld
  17. mov bx, -2d
  18. mov si, [bx]
  19. lea di, parameters
  20. ;si is used for locating video buffer
  21. ;di is used for locating pattern
  22. page_iteration:
  23. add bx, 2d
  24. cmp bx, 16d ;16 = 2 * 8 is number of pages
  25. je findPattern_exit
  26. mov si, video_pages[bx]
  27. lea di, parameters
  28. cmp_str_iteration:
  29. mov ax, video_pages[bx + 2] ;check pages' intervals
  30. cmp si, ax
  31. je page_iteration
  32. mov ax, es:[si]
  33. mov ah, ds:[di]
  34. add si, 2
  35. inc di
  36. ;equ
  37. cmp ah, al
  38. je cmp_str_iteration
  39. ;nequ
  40. mov ax, di ;ax holds fst not equ char
  41. lea di, parameters
  42. sub ax, di
  43. cmp ax, n
  44. jnz cmp_str_iteration
  45. ;equ_words
  46. mov video_offset, si
  47. mov ax, bx
  48. cwd
  49. div two
  50. mov npage, ax
  51. add al, '0'
  52. mov file_name[1], al ;al - page number
  53.  
  54. mov ah, 3dh ;open a file
  55. mov al, 1 ;write only
  56. lea dx, file_name
  57. int 21h
  58. jc create_and_open_file
  59. mov fd, ax
  60.  
  61. mov ah, 42h
  62. mov al, 2
  63. mov bx, fd
  64. mov cx, 0 ;upper portion of offset
  65. mov dx, 0 ;lower portion of offset
  66. int 21h
  67. mov errno, 2
  68. jc findPattern_error
  69. mov errno, -1
  70. jmp write_file
  71. create_and_open_file:
  72. mov ah, 3ch
  73. mov cx, 0
  74. lea dx, file_name
  75. int 21h
  76. mov errno, 1
  77. jc findPattern_error ;pop from stack ret?
  78. mov errno, -1
  79. mov fd, ax
  80. write_file:
  81. mov bx, npage
  82. mov ax, video_pages[bx] ;ax holds current video page offset
  83. mov bx, video_offset
  84. sub bx, ax ;[0..24][0..80]
  85. mov ax, bx
  86. cwd
  87. div row_size ;ax holds column
  88. cwd
  89. mul row_size ;bottom round
  90. mov bx, npage
  91. add ax, video_pages[bx] ;ax holds address of current column
  92.  
  93. mov dx, ax
  94.  
  95. mov ah, 40h
  96. mov bx, fd
  97. mov cx, 160d
  98. push ds
  99. push es
  100. pop ds ;ds - b800h
  101. int 21h
  102. mov errno, 3
  103. jc findPattern_error ;write error
  104. mov errno, -1
  105. pop ds
  106. mov ah, 3eh
  107. mov bx, fd ;close file
  108. int 21h
  109.  
  110. mov bx, npage
  111. jmp cmp_str_iteration
  112. findPattern_error:
  113. findPattern_exit:
  114. pop es
  115. pop ds
  116. popa
  117. iret
  118. new_int9 endp
  119.  
  120. cmd_length db 0
  121.  
  122. execErr db "Can't execute Can't specified program execute Can't execute Can't specified program execute", 10,13,'$'
  123. errno dw 0
  124. errLen db 27
  125. errorStr db "Invalid usage.",10,13,"$$$$$$$$$$$"
  126. db "Create file error.",10,13,"$$$$$$$"
  127. db "Move file pointer error.",10,13,'$'
  128. db "Write error.",10,13,"$$$$$$$$$$$$$"
  129. ;variables used to parse commandline
  130. ibord dw 0
  131. borders dw 3 dup(0)
  132. left equ 0
  133. right equ 2
  134. iparam dw -1
  135. parameters db 256 dup(0)
  136. pos dw 0
  137. n dw 0
  138. nstr equ 128
  139. fisrt equ 0
  140. second equ 128
  141.  
  142. old_int9 dd 0
  143.  
  144. file_name db "FX.TXT", 0
  145. fd dw 0
  146.  
  147. video_pages dw 0h, 1000h, 2000h, 3000h, 4000h, 5000h, 6000h, 7000h, 8000h
  148. video_offset dw 0
  149. npage dw 0
  150.  
  151. com_tail_size db 0
  152. com_tail db 127 dup(0Dh)
  153.  
  154. two dw 2d
  155. row_size dw 160d
  156. start:
  157. ;code to parse command line
  158. jmp install_handler
  159. install_handler:
  160. mov ah, 35h
  161. mov al, 09h
  162. int 21h
  163. mov word ptr old_int9, bx
  164. mov word ptr old_int9 + 2, es
  165.  
  166. mov ah, 25h
  167. mov al, 09h
  168. mov dx, offset new_int9
  169. int 21h
  170.  
  171. mov ax, 3100h
  172. mov dx, (start - start_resident + 10Fh) / 16
  173. int 21h
  174. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement