data segment ;yotam yehonatan B.4. tmp db 256 dup('$') last dw 00h Q db 2000h dup('$') A db 2000h dup('$') RA db 2000h dup('$') txt0 db ' 0 To exit ,1 to insert ,2 to talk $' txt1 db ' 1 insert qwestion $' txt2 db ' 2 insert answer $' txt3 db ' 3 insert random answer $' txt4 db ' insert sentence or press 4 to exit $' txt5 db ' not enough memory $' index dw 00h count dw 00h maxln db 20h data ends sseg segment stack dw 100 dup(?) sseg ends code segment assume ds:data,cs :code ,ss:sseg ;***************************** print ****************************** print proc near push ax push dx call line1 mov ah,09h int 21h call line1 pop dx pop ax ret print endp ;***************************** new line ****************************** line1 proc near push ax push dx mov ah,02 mov dl,0ah int 21h mov dl,0dh int 21h pop dx pop ax ret line1 endp ;***************************** insert ****************************** insert proc near push ax push bx push cx push dx push di mov bx,20h ag: call line1 mov dx,offset txt1 call print mov di,offset Q add di,last mov ah,01 ag1: int 21h cmp al,13 je next1 mov [di],al inc di jmp ag1 next1: mov dx,offset txt2 call print mov di,offset A add di,last mov ah,01 ag2: int 21h cmp al,13 je next2 mov [di],al inc di jmp ag2 next2: lea dx,txt3 call print mov di,offset RA add di,last mov ah,01 ag3: int 21h cmp al,13 je next3 mov [di],al inc di jmp ag3 next3:add last,bx mov dx,offset txt4 call print inc index int 21h cmp al,34h jne ag pop di pop dx pop cx pop bx pop ax ret insert endp ;***************************** Talk ****************************** Talk proc near push ax push bx push cx push dx push di push si cld mov bx,20h mov dx,offset txt1 call print agi: call line1 mov cx,index mov si,offset tmp ;geting string mov count,0 mov ah,01 agi2: int 21h cmp al,0dh ;press enter je agi0 mov [si],al inc si inc count jmp agi2 agi0: mov al,'$' mov [si],al mov di,offset Q agi1: mov si,offset tmp push di push cx mov cx,count agi3: cmpsb loopz agi3 ;mov al,[si] jz Ptruth ; cmp al,'$' ; je truth ;find same qwestion ;cmp al,[di] ;jne Pfal ; inc si ; inc di ; loop agi3 Pfal: pop cx ;go next string in Q array pop di add di,bx loop agi1 false: mov dx,offset RA ;random index chose random sentence ;add di,4000h ;mov dx,di call print jmp n3 Ptruth: mov al,[di] cmp al,'$' jne Pfal truth:pop cx pop di add di,2000h mov dx,di call print n3: mov dx,offset txt4 call print int 21h cmp al,34h jne agi pop si pop di pop dx pop cx pop bx pop ax ret Talk endp ;***************************** main ****************************** main proc far push ds ;for remmber data segment mov ax,00 push ax ;for remmber ip mov ax,data mov ds,ax mov es,ax mov cx,0 agin: lea dx,txt0 call line1 call print mov ah,01 int 21h cmp al,30h je sof cmp al,31h jne in1 call insert in1: cmp al,32h jne in2 call Talk in2: jmp agin sof: RET main endp code ends end main