Skip to content

Instantly share code, notes, and snippets.

@dector
Created April 2, 2011 20:39
Show Gist options
  • Save dector/899860 to your computer and use it in GitHub Desktop.
Save dector/899860 to your computer and use it in GitHub Desktop.
; Denys Mosiuk, IO-92
; KPI 2011
assume cs:code, ds:data, es:data
data segment
DELIMITER equ ' '
string db "A long time ago in a galaxy far far away. "
str_end db '$'
data ends
code segment
beg:
mov ax, data ; Init data segments
mov ds, ax
mov es, ax
mov cx, offset str_end - string
xor dl, dl
cld
mov al, DELIMITER
lea di, string
; <Enter> after each 5th
search: ; word
repne scasb ; Scan for DELIMITER
jne step
inc dl ; If found
cmp dl, 5 ; And there was 5th
jne step
mov byte ptr[di-1], 0ah ; Print nextline
xor dl, dl ; and clear counter
step:
or cx, cx ; Test for end of line
jnz search
lea bx, string ; Print corrected text
mov ah, 9
int 21h
mov ax, 4c00h ; Exit to DOS
int 21h
code ends
end beg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment