zas      segment stack 'stack'
         dw  200  dup(?)
zas      ends

data segment
         zadr  db 10,13,' Zadaj retazec:$'
	 vyppv db 10,13,' 1   - Vypis povodneho retazca.$'
	 medze db 10,13,' 2   - Najdenie prvej medzery.$'
	 cisli db 10,13,' 3   - Zisti pocet cislic.$'
	 hznak db 10,13,' 4   - Hladanie znaku.$'
	 opakr db 10,13,' 5   - Obrat retazec.$'
	 exit  db 10,13,' Esc - Koniec.$'
	 zadz  db 10,13,' Zadaj hladany znak: $'
	 pocc  db 10,13,' Pocet cislic v retazci je: $'
	 mmedz db 10,13,' Prva medzera je na pozicii: $'
vstup    db 100
poc	 db 0
pocet    db 0
         db  100 dup(0)
nrs	 db  10,13,'$'
nr       db  10
         db  13
vystup   db  103  dup (0)
data     ends

code     segment
         assume cs:code,ds:data,ss:zas
     
start:   mov  ax, seg data
         mov  ds,  ax
         mov  dx,  offset  zadr
         mov  ah,  9
         int  21h
         mov  dx,  offset  vstup
         mov  ah,  0ah
         int  21h

zacni:   call vypmenu
	 mov  ah,  1
         int  21h
         cmp  al, '1'
         jnz  d
	 call vypret
d:       cmp  al,  '2'
         jnz  d2
	 call pozmedz
d2:      cmp  al,  '3'
         jnz  d3
	 call  cislic
d3:      cmp  al,  '4'
         jnz  d4
	 call hladzn
d4:      cmp  al,  '5'
	 jnz  d5
	 call obraten
d5:	 cmp  al,  27
	 jnz  zacni
	 call koniec


vypmenu  proc
	 mov  dx,  offset  vyppv
         mov  ah,  9
         int  21h
         mov  dx,  offset  medze
         mov  ah,  9
         int  21h
         mov  dx,  offset  cisli
         mov  ah,  9
         int  21h
         mov  dx,  offset  hznak
         mov  ah,  9
         int  21h
	 mov  dx,  offset  opakr
	 mov  ah,  9
         int  21h
	 mov  dx,  offset  exit
	 mov  ah,  9
         int  21h
	 ret
	 endp

  
vypret   proc
         mov  dx,  offset  nrs
         mov  ah,09h
         int  21h
         mov  dx,  offset  vstup
	 add  dx,2
         mov  ah,09h
         int  21h
         ret
         endp
          
obraten  proc
         mov  dx,  offset  pocet
         inc  dx
         mov  si,  dx
         mov  cx,  [si]
         mov  ch,  0
           
         mov  bx,  offset  vystup
         add  bx,  cx  
         push  cx     
ob:      mov  ah,  [si]
         mov  [bx],  ah
         inc  si
         dec  bx
         loop  ob
         pop  cx
         inc  cx
         add  bx,  cx   
           

         mov  byte  ptr  [bx],  10
         mov  byte  ptr  [bx]+1,  13
         mov  byte  ptr  [bx]+2,  24h  
         mov  dx,  offset nr
         mov  ah,9
         int  21h
	 ret
	 endp

cislic   proc
	 mov  dx,  offset  vstup
	 add  dx,  2
	 mov  si,  dx
	 mov  bx,  offset  vystup
	 xor  cx,  cx
	 mov  cl,  pocet
	 xor  ax,  ax

znova:	 mov  al,[si]
	 cmp  al,30h
	 jbe  dalej
	 cmp  al,39h
	 jnb  dalej
	 inc  poc

dalej:	
	 mov  al,  [si]
	 mov  [bx],  al
	 inc  si
	 inc  bx
	 loopne  znova
;treba vypisat pocet cislic, pouzitie ukazanej procedury.




        
koniec:
	 mov  dx,  offset  text7
	 mov  ah,  9
	 int  21h
	 mov  ah,  1
	 int  21h
	 cmp  al,  'n'
	 jz   fine
         cmp  al,  'a'
         jz   start2
fine:
         mov  ax,  4c00h
	 int  21h 
code     ends
         end    start
        

    
    

