Advertisement
Guest User

Untitled

a guest
Oct 7th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .MODEL SMALL
  2. .STACK 200H
  3. .DATA
  4. Text db "He is painting. She was waiting. They will be coming.$"
  5. PunctuationMarks db ' ', '.', ',', ';', ':', ')', '!', '?', '$'
  6. ResultText db "$"
  7. .CODE
  8. START:
  9.  
  10. mov ax, @DATA
  11. mov ds, ax
  12.  
  13. lea dx, Text
  14. xor ax, ax
  15. mov ah, 09
  16. int 21h
  17.  
  18. xor dx, dx
  19. xor si, si
  20.  
  21. ; Text[0...2] --> ResultText[]
  22. FIRST_THREE_CHARS:
  23. mov al, [Text + si]
  24. mov [ResultText + si], al
  25. cmp al, '$'
  26. je End_Parse_text_loop
  27. inc si
  28. cmp si, 2
  29. jne FIRST_THREE_CHARS
  30. ; ---------------------------
  31.  
  32.  
  33. PARSE_TEXT_LOOP:
  34. mov al, [Text + si]
  35.  
  36. mov di, si
  37. sub di, dx
  38. mov [ResultText + di], al
  39.  
  40. cmp al, '$'
  41. je END_PARSE_TEXT_LOOP
  42.  
  43. cmp al, 'g'
  44. jne CONTINUE_PARSE_TEXT_LOOP
  45.  
  46. mov al, [Text + si + 1]
  47. cmp al, '$'
  48. je Cmp_al_n
  49.  
  50. xor bx, bx
  51. PUNCTUATION_MARKS_CHECK_LOOP:
  52. mov ah, [PunctuationMarks + bx]
  53. cmp ah, '$' ; $ - PunctuationMarks is end
  54. je CONTINUE_PARSE_TEXT_LOOP
  55. cmp al, ah
  56. je CMP_AL_N
  57. inc bx
  58. jmp PUNCTUATION_MARKS_CHECK_LOOP
  59.  
  60. CMP_AL_N:
  61. mov al, [Text + si - 1]
  62. cmp al, 'n'
  63. jne  CONTINUE_PARSE_TEXT_LOOP
  64. mov al, [Text + si - 2]
  65. cmp al, 'i'
  66. jne CONTINUE_PARSE_TEXT_LOOP
  67.  
  68. mov [ResultText + di - 1], 'd'
  69. mov [ResultText + di - 2], 'e'
  70. inc dx
  71.  
  72. CONTINUE_PARSE_TEXT_LOOP:
  73. inc si
  74. jmp PARSE_TEXT_LOOP
  75.  
  76. END_PARSE_TEXT_LOOP:
  77. ; ------ new line
  78. mov dl, 0dh
  79. mov ah, 02h
  80. int 21h
  81. mov dl, 0ah
  82. mov ah, 02h
  83. int 21h
  84. ; ------
  85.  
  86. lea dx, ResultText
  87. xor ax, ax
  88. mov ah, 09
  89. int 21h
  90.  
  91. mov ah, 4ch
  92. mov al, 00h
  93. int 21h
  94.  
  95. END START
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement