Advertisement
Neveles

Untitled

Dec 19th, 2019
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DOSSEG
  2. .MODEL TINY
  3. .STACK 100h
  4. .DATA
  5. inputFile DB 'input.txt',0
  6. outputFile DB 'outputFile.txt',0    
  7. error_file DB 'Cannot open file!',0,13,10
  8. text DB 1000 DUP('$')
  9. buff DB '2', '$'
  10. .CODE
  11. .386
  12.  
  13. inFile macro str
  14.  mov ah, 40h
  15.  push bx
  16.  mov bx, di
  17.  mov cx, 1
  18.  lea si, buff
  19.  mov [si], str
  20.  mov dx, si
  21.  int 21h  
  22.  pop bx  
  23. endm
  24.  
  25. start:
  26. mov ax, @Data
  27. mov ds, ax
  28. mov es, ax
  29.  
  30. ; otkritie fayla
  31. mov ah, 3Dh
  32. mov al, 0
  33. lea dx, inputFile
  34. int 21h
  35. jc error_no_file
  36.    
  37. mov si, ax        
  38.  
  39. ; chtenie fayla
  40. lea dx, text
  41.  
  42. reading_file:
  43.  mov ah, 3Fh
  44.  mov bx, si
  45.  mov cx, 1
  46.  int 21h  
  47.  inc dx  
  48.  cmp ax, 1        
  49.  je reading_file
  50.  
  51. ; zakritie fayla
  52.  mov ah, 3Eh
  53.  mov bx, si
  54.  int 21h    
  55.  
  56. ; sozdanie fayla
  57. mov al, 1h
  58. mov ah, 3Ch
  59. mov cx, 0
  60. lea dx, outputFile
  61. int 21h
  62. mov di, ax
  63.  
  64. ; osnovnaya chast
  65. mov cx, 0
  66. mov bx, OFFSET text
  67. mov dx, bx
  68.  
  69. main_iteration:
  70.  cmp cx, 0
  71.  je met
  72.  add bx, 1
  73.  met:
  74.  mov cx, 1
  75.  mov al, [bx]  
  76.  
  77.  cmp al, 41h    ; A
  78.  je printword
  79.  cmp al, 45h    ; E
  80.  je printword  
  81.  cmp al, 49h    ; I
  82.  je printword
  83.  cmp al, 4Fh    ; O
  84.  je printword
  85.  cmp al, 55h    ; U
  86.  je printword  
  87.  cmp al, 59h    ; Y
  88.  je printword    
  89.      
  90.  cmp al, 61h    ; a
  91.  je printword
  92.  cmp al, 65h    ; e
  93.  je printword  
  94.  cmp al, 69h    ; i
  95.  je printword
  96.  cmp al, 6Fh    ; o
  97.  je printword
  98.  cmp al, 75h    ; u
  99.  je printword  
  100.  cmp al, 79h    ; y
  101.  je printword
  102.    
  103.  jmp skipword
  104.  
  105. printword:
  106.  mov ah, 2
  107.  mov dl, al
  108.  int 21h  
  109.  inFile al    
  110.  cmp al, 20h
  111.  jz main_iteration
  112.  
  113. signs:      
  114.  cmp [bx + 1], ah
  115.  jz printspace
  116.  add ah, 1
  117.  cmp ah, 30h
  118.  jbe signs
  119.  add bx, 1
  120.  mov al, [bx]
  121.  cmp al, 13
  122.  jz quit
  123.  jmp printword
  124.  
  125. skipword:
  126.  cmp al, 20h
  127.  jz main_iteration
  128.  add bx, 1
  129.  mov al, [bx]
  130.  cmp al, 13
  131.  jz quit
  132.  jmp skipword
  133.  
  134. printspace:
  135.  mov ah, 2
  136.  mov dl, 20h
  137.  int 21h
  138.  inFile 20h
  139.  jmp main_iteration
  140.  
  141. quit:
  142.  mov ah, 2
  143.  mov dl, 10
  144.  int 21h
  145.  mov ah, 3Eh
  146.  mov bx, di
  147.  int 21h    
  148.  mov ah, 4ch
  149.  int 21h
  150.  
  151. error_no_file:  
  152.  lea dx, error_file
  153.  mov ah, 9h
  154.  int 21h
  155.  mov ah, 4ch
  156.  int 21h
  157.  
  158. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement