Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- code_seg segment para public
- assume cs:code_seg,ds:data_seg,ss:stack_seg
- ;CR
- ;Carriage return and line feed
- cr proc
- push ax
- push dx
- mov ah, 02h
- mov dl, 10
- int 21h
- pop dx
- pop ax
- ret
- cr endp
- ;Show message
- ;Prints string from offset in dx
- message proc
- push ax
- mov ah, 09h
- ; mov dx, offset src_msg
- int 21h
- pop ax
- ret
- message endp
- get_file_path proc
- push ax
- push bx
- push cx
- mov ah, 3fh ;Read file DOS function
- ; mov dx, offset source
- mov cx, 256
- mov bx, 0 ;Reading from STDIN
- int 21h
- call cr
- pop cx
- pop bx
- pop ax
- ret
- get_file_path endp
- open_source proc
- push ax
- mov ah, 3dh
- mov al, 0
- int 21h
- jc no_src ;If CF is set, then something is wrong with file, GTFO
- mov ,ax
- no_src:
- pop ax
- ret
- open_source endp
- open_dest proc
- mov ah, 3dh
- mov al, 0
- ret
- open_dest endp
- start:
- ;Populating segment adresses
- mov ax, data_seg
- mov ds, ax
- mov ax, stack_seg
- mov ss, ax
- mov dx, offset source
- call get_file_path
- call open_source
- jc exit ;Returned from open_source, if CF is set, then exit
- mov dx, offset dest
- call get_file_path
- call open_dest
- ;exit
- exit:
- call cr
- mov ah, 4ch
- int 21h
- code_seg ends
- data_seg segment para public
- source db 257 dup (0dh)
- dest db 257 dup (0dh)
- buffer db 514 dup (0h)
- src_desc dw 1 dup (0h)
- dst_desc dw 1 dup (0h)
- src_msg db 'Enter source file name: $'
- dst_msg db 'Enter destination file name: $'
- no_src_msg db 'Something wrong with source file.'
- data_seg ends
- stack_seg segment para stack
- db 255 dup("!")
- stack_seg ends
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement