.model small
.data
strarry db 'act'
db 'art'
db 'dog'
db 'cat'
db 'ant','$'
strlen db 3
tmpSi dw ?
tmpDi dw ?
tmp db 3 dup(' ')
cnt1 db 1
cnt2 db 0
.code
mov ax,@data
mov ds,ax
mov es,ax
mov SI,00
mov DI,00
mov BX,00
outer:
LEA SI,strarry[BX]
mov tmpSi, SI
mov DI,SI
add DI,3
mov dh,cnt1
mov cnt2,dh
inner:
mov cx,3
mov tmpDi,DI
repe CMPSB
jl swap
add cnt2,1
cmp cnt2,5
je incbx
add tmpDi,3
mov DI,tmpDi
mov SI,tmpSi
jmp inner
incbx:
add cnt1,1
cmp cnt1,5
je ext
add BX,3
add cnt2,1
jmp outer
jmp ext
swap:
mov cx,3
mov SI,tmpSi
LEA DI,tmp
rep MOVSB
mov cx,3
mov SI,tmpDi
mov DI,tmpSi
rep MOVSB
mov cx,3
mov DI,tmpDi
LEA SI, tmp
rep MOVSB
add cnt2,1
cmp cnt2,5
je incbx
add tmpDi,3
mov DI,tmpDi
mov SI,tmpSi
jmp inner
ext:
mov ax,0900h
LEA DX,strarry
int 21h
mov ax,4C00h
int 21h
end