Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 100h
- .data
- text db 'ZZZ gtP GT ZZZ','$'
- bufer db 999 dup('$')
- array_of_word_big dw 99 dup(0)
- array_of_word_pos dw 99 dup(0)
- array_of_word_end dw 99 dup(0)
- text_a db "input string: $"
- text_b db "output string: $"
- endl db 10,13,'$'
- .code
- start:
- mov ax, @data
- mov ds, ax
- mov si, 0
- mov di, 0
- jmp _find_data_length
- _find_data_length_step:
- inc di
- _find_data_length:
- cmp text[di], '$'
- je _find_data_length_end
- jmp _find_data_length_step
- _find_data_length_end:
- ;di - text len
- mov ax, 0
- mov cx, 0
- mov bx, 0
- _find_new_word:
- cmp text[si], ' '
- je _new_word_found
- cmp si, di
- je _new_word_found
- cmp text[si], 'A'
- jl _not_big
- cmp text[si], 'Z'
- jg _not_big
- inc ax
- _not_big:
- inc si
- jmp _find_new_word
- _new_word_found:
- mov array_of_word_big[bx], ax
- mov array_of_word_pos[bx], cx
- mov array_of_word_end[bx], si
- inc si
- add bx, 2
- mov ax, 0
- mov cx, si
- cmp si, di
- jge _end_of_text_scan
- jmp _find_new_word
- _end_of_text_scan:
- mov si, bx
- mov ax, 0 ; min
- mov cx, 0 ; max
- mov bx, 0
- ;find min
- jmp _find_min_max_word
- _find_min_max_word_step:
- add bx, 2
- _find_min_max_word:
- cmp bx, si
- jge _find_min_max_word_end
- push bx
- mov bx, ax
- mov dx, array_of_word_big[bx]
- pop bx
- cmp array_of_word_big[bx], dx
- jge _skip_min
- mov ax, bx
- _skip_min:
- push bx
- mov bx, cx
- mov dx, array_of_word_big[bx]
- pop bx
- cmp array_of_word_big[bx], dx
- jle _skip_max
- mov cx, bx
- _skip_max:
- jmp _find_min_max_word_step
- _find_min_max_word_end:
- mov bx, ax
- mov dx, array_of_word_pos[bx]
- push dx
- mov dx, array_of_word_end[bx]
- push dx
- mov bx, cx
- mov dx, array_of_word_pos[bx]
- mov bx, ax
- mov array_of_word_pos[bx], dx
- mov bx, cx
- mov dx, array_of_word_end[bx]
- mov bx, ax
- mov array_of_word_end[bx], dx
- mov bx, cx
- pop dx
- mov array_of_word_end[bx], dx
- pop dx
- mov array_of_word_pos[bx], dx
- mov cx, si
- mov ax, 0
- mov bx, 0
- jmp _word_loop
- _word_loop_step:
- add ax, 2
- _word_loop:
- cmp ax, cx
- jge _word_loop_end
- push bx
- mov bx, ax
- mov si, array_of_word_pos[bx]
- mov di, array_of_word_end[bx]
- pop bx
- jmp _copy_loop
- _copy_loop_step:
- inc bx
- inc si
- _copy_loop:
- cmp si, di
- jge _copy_loop_end
- mov dh, text[si]
- mov bufer[bx], dh
- jmp _copy_loop_step
- _copy_loop_end:
- mov bufer[bx], ' '
- inc bx
- jmp _word_loop_step
- _word_loop_end:
- dec bx
- mov bufer[bx], '$'
- Print MACRO str
- push ax
- push dx
- mov ah, 09h
- mov dx, offset str
- int 21h
- pop dx
- pop ax
- ENDM Print
- Print text_a
- Print endl
- Print text
- Print endl
- Print text_b
- Print endl
- Print bufer
- Print endl
- mov ax, 4c00h
- int 21h
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement