;Pide dos números y nos dice cual es mayor pila segment stack 'stack' db 128 dup(?) pila ends datos segment bufnum1 db 6,?,6 dup (?),'$' bufnum2 db 6,?,6 dup (?),'$' introd1 db 'Introduce num1',10,13,'$' introd2 db 'Introduce num2',10,13,'$' iguales db 'Ambos numeros son iguales',10,13,'$' cad1 db 'Num1 es mayor que num2',10,13,'$' cad2 db 'Num2 es mayor que num1',10,13,'$' num1 dw ? num2 dw ? datos ends codigo segment assume cs:codigo,ds:datos,ss:pila principal proc far push ds sub ax,ax push ax mov ax,datos mov ds,ax mov ah,9 mov dx,offset introd1 int 21h mov ah,0ah mov dx,offset bufnum1 int 21h mov ah,9 mov dx,offset introd2 int 21h mov ah,0ah mov dx,offset bufnum2 int 21h mov ax,offset bufnum1 push ax mov ax,offset num1 push ax call pasar mov ax,offset bufnum2 push ax mov ax,offset num2 push ax call pasar mov ax,num1 mov bx,num2 cmp ax,bx jne sigue mov ah,9 mov dx,offset iguales int 21h jmp fin2 sigue: cmp ax,bx jns continua mov ah,9 mov dx,offset cad2 int 21h jmp fin2 continua: mov ah,9 mov dx,offset cad1 int 21h jmp fin2 fin2: retf principal endp pasar proc push bp push si push di push ax push bx push cx push dx mov bp,sp mov si,18[bp] ;dir del bufnum mov di,16[bp] ;dir del num mov cx,10 inc si xor bx,bx mov bl,[si] ;apunto bx a la derecha del buffer xor ax,ax mov al,[si][bx] xor dx,dx ;incializo el acumulador sub al,'0' add dl,al dec bx cmp bx,0 je fin ;si el numero tiene una sola cifra bucle: xor ax,ax mov al,[si][bx] sub al,'0' push dx mul cx pop dx add dx,ax mov ax,10 push dx mul cx pop dx mov cx,ax dec bx ;jns bucle cmp bx,0 jne bucle fin: mov [di],dx ;devuelvo el valor del numero correspondiente pop dx pop cx pop bx pop ax pop di pop si pop bp ret 4 pasar endp codigo ends end principal