.model small
.stack 100h
.data
        m1 DB '1. vypis retazca na obrazovku', 13, 10, '$'
        m2 DB '2. vypis pozicie prvej medzery', 13, 10, '$'
        m3 DB '3. spocitanie a vypis pocet cislic v retazci', 13, 10, '$'
        m4 DB '4. najdi znak a vypis jeho pozicie', 13, 10, '$'
        m5 DB '5. vypis v obratenom poradi', 13, 10, '$'
        m6 DB '6. koniec', 13, 10, '$'
        MAX     EQU     100
        LengthOS        DB 0
        MyString        DB MAX  DUP (?)
        ReverseString   DB MAX  DUP (?)
        Buffer          DB 9    DUP (0)
.code
;--------------------------------------------------------------------------------------------
        PrintString proc
                mov ah, 40h
                mov bx, 01h
                mov dx, OFFSET MyString
                int 21h
                ret
        endp
;--------------------------------------------------------------------------------------------
        CountPrintDigits proc
                xor dx, dx                              ; uchova celkovy sucet
                xor cx, cx                              ; spocita kolko cislicje v retazci
                mov si, OFFSET MyString
                OutLoop :       mov ax, [si]
                                cmp ax, 39h             ; '9'
                                ja OutLoop
                                cmp ax, 30h             ; '0'
                                jb OutLoop
                                sub ax, 30h
                                inc cx
                                add dx, ax
                                inc si
                                mov bx, '$'
                                cmp [si], bx
                                jnz OutLoop
                                                        ;tato cast spravi, aby sa dali reg. dx, cx vytpisat na obr.
-> vloz desiatkovu delicku + vypis
                ret
        endp
;--------------------------------------------------------------------------------------------
        FindSpace proc
                xor cx, cx
                mov si, OFFSET MyString
                FindLoop :      mov al, [si]
                                cmp al, ' '
                                jz EOP
                                inc cx
                                inc si
                                cmp [si], '$'
                                jz EOP
                                jmp FindLoop
                EOP :
-> vloz desiatkovu delicku + vypis
                ret
        endp
;--------------------------------------------------------------------------------------------
        FindChar proc

-> vloz desiatkovu delicku + vypis
                ret
        endp
;--------------------------------------------------------------------------------------------
        ReverseString proc
-> vloz desiatkovu delicku + vypis
                ret
        endp
;--------------------------------------------------------------------------------------------
        start : mov ax, @DATA                   ; udanie adresy datoveho segmetu
                mov ds, ax                      ; nacitanie retazca na operacie cez input handle
                mov dx, OFFSET MyString
                mov cx, MAX
                mov bx, 00h
                mov ah, 3fh
                int 21h
                mov Length, ax                  ; zachovaj dlzku retazca
                mov dx, OFFSET m1               ; zaciatok menu1
                mov ah, 09h
                int 21h
                mov dx, OFFSET m2               ; zaciatok menu2
                mov ah, 09h
                int 21h
                mov dx, OFFSET m3               ; zaciatok menu3
                mov ah, 09h
                int 21h
                mov dx, OFFSET m4               ; zaciatok menu4
                mov ah, 09h
                int 21h
                mov dx, OFFSET m5               ; zaciatok menu5
                mov ah, 09h
                int 21h
                mov dx, OFFSET m6               ; zaciatok menu6
                mov ah, 09h
                int 21h
                mov ah, 01h                     ; nacitanie vstupneho znaku pre vyber z menu
                int 21h
                cmp al, 06h                     ; porovnanie so 6. polozkou menu
                jz konec
                cmp al, 01h                     ; porovnanie so 1. polozkou menu
                jz PrintString
                cmp al, 02h
                jz FindSpace
                cmp al, 03h
                jz CountPrintDigits
                cmp al, 04h
                jz FindChar
                cmp al, 05h
                jz ReverseString
        konec : mov ah, 4ch
                int 21h
end
















