; this program asks the user to enter two numbers, and decides whether ; the first or the second entered number is bigger. .model small .stack .data text1 db 'Enter first number: $' text2 db 'Enter second number: $' text3 db 'First is bigger.',10,13,'$' text4 db 'Second is bigger.',10,13,'$' text5 db 'Equal numbers.',10,13,'$' new_line db 10, 13, '$' .code start: mov ax, _data ; ds - data segment mov ds, ax mov ax, 3 ; clear screen int 10h mov ah, 9 ; text1 to screen lea dx, text1 int 21h mov ah, 1 ; read char int 21h push ax ; char to stack mov ah, 9 ; jump to the start of the next line lea dx, new_line int 21h mov ah, 9 ; text2 to screen lea dx, text2 int 21h mov ah, 1 ; read char int 21h push ax ; second char to stack mov ah, 9 ; jump to the start of the next line lea dx, new_line int 21h pop cx ; second char from stack to cx pop bx ; first char from stack to bx cmp bx,cx ; compare chars je lab_equal cmp bx,cx ; compare chars jg lab_first mov ah, 9 ; text4 to screen lea dx, text4 int 21h jmp vege lab_equal: mov ah, 9 ; text 5 to screen lea dx, text5 int 21h jmp vege lab_first: mov ah, 9 ; text3 to screen lea dx, text3 int 21h vege: mov ax,4c00h ; exit int 21h end start -------------------- .model small .stack .data text1 db "Enter x to print x: $" text2 db "Not x.",10,13,'$' new_line db 10,13,'$' .code start: mov ax,_data mov ds,ax mov ax,3 int 10h mov ah,9 lea dx, text1 int 21h mov ah,1 int 21h push ax mov ah,9 lea dx,new_line int 21h pop ax cmp al,'x' je label1 mov ah,9 lea dx,text2 int 21h jmp kraj label1: mov ax,0b800h mov es,ax mov cx,12 mov di,400 mov al,'' mov ah,01011010b label2: mov es:[di],ax add di,162 loop label2 mov cx,12 mov di,420 mov al,'' mov ah,01011010b label3: mov es:[di],ax add di,158 loop label3 kraj: mov ax,4c00h int 21h end start ---------------------------------- .model small .stack .data text1 db "Enter x to print x: $" text2 db "Not x. Try again: $" new_line db 10,13,'$' .code start: mov ax,_data mov ds,ax mov ax,3 int 10h mov ah,9 lea dx, text1 int 21h mov ah,1 int 21h push ax mov ah,9 lea dx,new_line int 21h pop ax cmp al,'x' je label1 label4: mov ah,9 lea dx,text2 int 21h mov ah,1 int 21h push ax mov ah,9 lea dx,new_line int 21h pop ax cmp al,'x' jne label4 label1: mov ax,0b800h mov es,ax mov cx,12 mov di,400 mov al,'' mov ah,01011010b label2: mov es:[di],ax add di,162 loop label2 mov cx,12 mov di,420 mov al,'' mov ah,01011010b label3: mov es:[di],ax add di,158 loop label3 mov ax,4c00h int 21h end start ------------------------------ ; this program asks the user to enter two characters, and calculates ; the difference .model small .stack .data text1 db 'Enter first number: $' text2 db 'Enter second number: $' text3 db 'Suma= $' text4 db 'Difference: ','$' new_line db 10, 13, '$' .code start: mov ax, _data mov ds, ax mov ax, 3 int 10h mov ah, 9 lea dx, text1 int 21h mov ah, 1 int 21h push ax mov ah, 9 lea dx, new_line int 21h mov ah, 9 lea dx, text2 int 21h mov ah, 1 int 21h push ax mov ah, 9 lea dx, new_line int 21h pop cx pop bx cmp bx,cx jnl label1 mov ah, 9 lea dx, text4 int 21h mov ah, 2 mov dl, '-' int 21h sub cx,bx add cx,48 mov ah,2 mov dx,cx int 21h jmp label2 label1: mov ah, 9 lea dx, text4 int 21h sub bx,cx add bx,48 mov ah,2 mov dx,bx int 21h label2: mov ax,4c00h int 21h end start ----------------------------------------