Advertisement
Guest User

Untitled

a guest
Sep 9th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 1.84 KB | None | 0 0
  1. code_seg segment para public
  2.  
  3. assume cs:code_seg,ds:data_seg,ss:stack_seg
  4.  
  5. ;CR
  6. ;Carriage return and line feed
  7. cr proc
  8.     push ax
  9.     push dx
  10.     mov  ah, 02h
  11.     mov  dl, 10
  12.     int  21h
  13.     pop  dx
  14.     pop  ax
  15.     ret  
  16. cr endp
  17.  
  18. ;Show message
  19. ;Prints string from offset in dx
  20. message proc
  21.     push ax
  22.     mov ah, 09h
  23. ;   mov dx, offset src_msg
  24.     int 21h
  25.     pop ax
  26.     ret
  27. message endp
  28.  
  29. get_file_path proc
  30.     push ax
  31.     push bx
  32.     push cx
  33.    
  34.     mov ah, 3fh ;Read file DOS function
  35. ;   mov dx, offset source
  36.     mov cx, 256
  37.     mov bx, 0   ;Reading from STDIN
  38.     int 21h
  39.  
  40.     call cr
  41.    
  42.     pop cx
  43.     pop bx
  44.     pop ax
  45.    
  46.     ret
  47. get_file_path endp
  48.  
  49. open_source proc
  50.     push ax
  51.    
  52.     mov ah, 3dh
  53.     mov al, 0
  54.     int 21h
  55.    
  56.     jc no_src ;If CF is set, then something is wrong with file, GTFO
  57.    
  58.     mov ,ax
  59.    
  60. no_src:
  61.     pop ax
  62.     ret
  63.  
  64. open_source endp
  65.  
  66. open_dest proc
  67.     mov ah, 3dh
  68.     mov al, 0
  69.    
  70.     ret
  71. open_dest endp
  72.  
  73. start:
  74. ;Populating segment adresses
  75.     mov ax, data_seg
  76.     mov ds, ax
  77.     mov ax, stack_seg
  78.     mov ss, ax
  79.    
  80.     mov dx, offset source
  81.     call get_file_path
  82.     call open_source
  83.     jc exit ;Returned from open_source, if CF is set, then exit
  84.    
  85.     mov dx, offset dest
  86.     call get_file_path
  87.     call open_dest
  88.    
  89.     ;exit
  90. exit:
  91.     call cr
  92.     mov ah, 4ch
  93.     int 21h
  94.    
  95. code_seg ends
  96.  
  97. data_seg segment para public
  98.     source db 257 dup (0dh)
  99.     dest   db 257 dup (0dh)
  100.    
  101.     buffer db 514 dup (0h)
  102.    
  103.     src_desc dw 1 dup (0h)
  104.     dst_desc dw 1 dup (0h)
  105.    
  106.     src_msg db 'Enter source file name: $'
  107.     dst_msg db 'Enter destination file name: $'
  108.     no_src_msg db 'Something wrong with source file.'
  109. data_seg ends
  110.  
  111. stack_seg segment para stack
  112.     db 255 dup("!")
  113. stack_seg ends
  114.  
  115. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement