Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model tiny
- .code
- org 100h
- jmp start
- start_resident:
- new_int9 proc far ;must be far + iret
- pushf
- call cs:old_int9
- pusha
- push ds
- push es
- push cs
- pop ds
- mov ax, 0b800h
- mov es, ax
- cld
- mov bx, -2d
- mov si, [bx]
- lea di, parameters
- ;si is used for locating video buffer
- ;di is used for locating pattern
- page_iteration:
- add bx, 2d
- cmp bx, 16d ;16 = 2 * 8 is number of pages
- je findPattern_exit
- mov si, video_pages[bx]
- lea di, parameters
- cmp_str_iteration:
- mov ax, video_pages[bx + 2] ;check pages' intervals
- cmp si, ax
- je page_iteration
- mov ax, es:[si]
- mov ah, ds:[di]
- add si, 2
- inc di
- ;equ
- cmp ah, al
- je cmp_str_iteration
- ;nequ
- mov ax, di ;ax holds fst not equ char
- lea di, parameters
- sub ax, di
- cmp ax, n
- jnz cmp_str_iteration
- ;equ_words
- mov video_offset, si
- mov ax, bx
- cwd
- div two
- mov npage, ax
- add al, '0'
- mov file_name[1], al ;al - page number
- mov ah, 3dh ;open a file
- mov al, 1 ;write only
- lea dx, file_name
- int 21h
- jc create_and_open_file
- mov fd, ax
- mov ah, 42h
- mov al, 2
- mov bx, fd
- mov cx, 0 ;upper portion of offset
- mov dx, 0 ;lower portion of offset
- int 21h
- mov errno, 2
- jc findPattern_error
- mov errno, -1
- jmp write_file
- create_and_open_file:
- mov ah, 3ch
- mov cx, 0
- lea dx, file_name
- int 21h
- mov errno, 1
- jc findPattern_error ;pop from stack ret?
- mov errno, -1
- mov fd, ax
- write_file:
- mov bx, npage
- mov ax, video_pages[bx] ;ax holds current video page offset
- mov bx, video_offset
- sub bx, ax ;[0..24][0..80]
- mov ax, bx
- cwd
- div row_size ;ax holds column
- cwd
- mul row_size ;bottom round
- mov bx, npage
- add ax, video_pages[bx] ;ax holds address of current column
- mov dx, ax
- mov ah, 40h
- mov bx, fd
- mov cx, 160d
- push ds
- push es
- pop ds ;ds - b800h
- int 21h
- mov errno, 3
- jc findPattern_error ;write error
- mov errno, -1
- pop ds
- mov ah, 3eh
- mov bx, fd ;close file
- int 21h
- mov bx, npage
- jmp cmp_str_iteration
- findPattern_error:
- findPattern_exit:
- pop es
- pop ds
- popa
- iret
- new_int9 endp
- cmd_length db 0
- execErr db "Can't execute Can't specified program execute Can't execute Can't specified program execute", 10,13,'$'
- errno dw 0
- errLen db 27
- errorStr db "Invalid usage.",10,13,"$$$$$$$$$$$"
- db "Create file error.",10,13,"$$$$$$$"
- db "Move file pointer error.",10,13,'$'
- db "Write error.",10,13,"$$$$$$$$$$$$$"
- ;variables used to parse commandline
- ibord dw 0
- borders dw 3 dup(0)
- left equ 0
- right equ 2
- iparam dw -1
- parameters db 256 dup(0)
- pos dw 0
- n dw 0
- nstr equ 128
- fisrt equ 0
- second equ 128
- old_int9 dd 0
- file_name db "FX.TXT", 0
- fd dw 0
- video_pages dw 0h, 1000h, 2000h, 3000h, 4000h, 5000h, 6000h, 7000h, 8000h
- video_offset dw 0
- npage dw 0
- com_tail_size db 0
- com_tail db 127 dup(0Dh)
- two dw 2d
- row_size dw 160d
- start:
- ;code to parse command line
- jmp install_handler
- install_handler:
- mov ah, 35h
- mov al, 09h
- int 21h
- mov word ptr old_int9, bx
- mov word ptr old_int9 + 2, es
- mov ah, 25h
- mov al, 09h
- mov dx, offset new_int9
- int 21h
- mov ax, 3100h
- mov dx, (start - start_resident + 10Fh) / 16
- int 21h
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement