SHARE
TWEET

Untitled

a guest Apr 1st, 2019 124 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. format MZ
  2. entry code_seg:start  
  3. stack 200h
  4.  
  5. segment data_seg  
  6. ;bannedSymbols db 'abc', 0
  7. ;bannedNum db 3    
  8. thechar db 065h ; e
  9. oldCX dw 0
  10. oldSI dw 0
  11. file1 db 'data.txt', 0
  12. file2 db 'answer.txt', 0
  13. buffer db 80 dup (0)
  14. towrite db 80 dup (0) ; write to file
  15. length dw 0
  16. handle rw 1
  17. handle2 rw 1
  18. ;bgn db 0
  19. ;fnsh db 0
  20.    
  21. segment code_seg
  22. start:  mov ax,data_seg            
  23.         mov ds,ax    
  24.         call open_file        
  25.         call read_file
  26.        
  27.         mov [ds:length], ax  ; number of read bytes
  28.         call create_file
  29.         mov cx, [ds:length]
  30.         mov bp, 0   ; fowrite's iterator
  31.         mov si, 0   ; buffer's iterator
  32.         metka:
  33.             mov dl, [ds:buffer + si]            
  34.             mov [ds:towrite + bp], dl
  35.            
  36.             cmp [ds:towrite + bp], 0Ah ; new line
  37.             jz onecharcheck
  38.             afternewline:
  39.            
  40.             inc bp
  41.             inc si                        
  42.         loop metka
  43.        
  44. mov bx,[ds:handle]                  
  45. call close_file  
  46. mov bx, [ds:handle2]
  47. call close_file
  48.      
  49. mov ax, 4C00h    
  50. int 21h
  51.  
  52.  
  53. onecharcheck:
  54.     mov [ds:oldCX], cx
  55.     mov [ds:oldSI], si
  56.     xor al, al ; success      
  57.     inc bp ;;;;;;
  58.     mov cx, bp ; towrite's length  
  59.     mov ah, 065h ; char
  60.     c1:    
  61.         mov si, cx
  62.         cmp [ds:towrite+si], ah
  63.         jnz notmatch
  64.         mov al, 1
  65.         mov cx, 1                              
  66.         notmatch:    
  67.     loop c1
  68.    
  69.     cmp al, 1           ;if the line has char, it wont be written
  70.     jz notwrite
  71.     call write_line
  72.     notwrite:                    
  73.                  
  74.     mov cx, [ds:oldCX]
  75.     mov si, [ds:oldSI]
  76.     ;xor bp, bp
  77.     mov bp, -1
  78.     jmp afternewline
  79.    
  80. write_line:
  81.     mov ah, 40H
  82.     mov bx, [ds:handle2]
  83.     lea dx, [ds:towrite]
  84.     mov cx, bp
  85.     int 21h
  86.     jmp notwrite
  87.  
  88. create_file:
  89.     mov ah, 3ch
  90.     lea dx, [ds:file2]    
  91.     xor cx,cx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;????????
  92.     int 21h
  93.     mov [ds:handle2], ax
  94.     ret
  95.    
  96. open_file:
  97.     xor al, al
  98.     xor cx, cx
  99.     lea dx, [ds:file1]    ; string pointer to dx        
  100.     mov ah, 3Dh
  101.     int 21h    
  102.     mov [ds:handle], ax   ; file descriptor
  103.     ret
  104.    
  105. read_file:
  106.     mov bx, [ds:handle]
  107.     mov ah,3Fh
  108.     lea dx, [ds:buffer]
  109.     mov cx, 80
  110.     int 21h  
  111.     ret        
  112.    
  113. close_file:
  114.     mov ah,3Eh                    
  115.     int 21h
  116.     ret
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top