Código de división, multiplicación, suma y resta en EMU8086

                                                 .model small

.stack 100h


.data

    msg1 db 10,13,      "1.- Realizar Suma",0DH,0AH,"$"

    msg2 db             "2.- Realizar Resta",0DH,0AH,"$"

    msg3 db             "3.- Realizar Multiplicacion",0DH,0AH,"$"

    msg4 db             "4.- Realizar Division",0DH,0AH,"$"

    msg5 db             "5.- Salir",0DH,0AH,"$" 

    

    n1 db "1.- Edinson Yahir Sanchez Velazquez" 


    

    msg7 db             "!! Seleccione una opcion del menu !!",0DH,0AH,"$"

     

    num1 db 10,13,    "Ingrese el primer numero: ",0DH,0AH,"$"

    nom1 db ? 

    num2 db 10,13,    "Ingrese el segundo numero:",0DH,0AH,"$"

    result db 10,13,"El resultado es: ",0DH,0AH,"$"

    

    final db 10,13,     "!! PROGRAMA FINALIZADO !!"

    

.code


programa:

    mov ax, @data 

    mov ds, ax

    jmp mostrarmenu

      

  mostrarmenu:

  mov dx, offset msg1

  call imprimir

  mov dx, offset msg2

  call imprimir

  mov dx, offset msg3 

  call imprimir

  mov dx, offset msg4

  call imprimir

  mov dx, offset msg5

  call imprimir

  

  mov dx, offset msg7

  call imprimir 

  mov ah,01h

  int 21h

  mov dl,al

  

  cmp dl,31h

  je opcion1 

  

  cmp dl,32h 

  je opcion2 

  

  cmp dl,33h

  je opcion3

  

  cmp dl,34h

  je opcion4

  

  cmp dl,35h

  je opcion5

  

  

  

  jnp mostrarmenu

    

    ;Bloque de suma

    opcion1:

    mov dx, offset num1

    call imprimir

    mov ah,1h

    int 21h

    

    add nom1,al

    sub nom1, 30h

    

    mov dx, offset num2

    call imprimir

    mov ah,1h

    int 21h

    

    

    add nom1,al

    sub nom1, 30h

    

       

    mov dx, offset result

    call imprimir

    

    add nom1, 30h

    mov ah, 2h

    mov dl,nom1

    int 21h

    

    

    jmp mostrarmenu

    

    ;Bloque de resta

    opcion2:

    mov dx, offset num1

    call imprimir

    mov ah,1h

    int 21h

    

    mov dx, offset num2

    call imprimir

    mov ah,1h

    int 21h

    mov dx, offset result

    call imprimir

    jmp mostrarmenu

    

    ;Bloque de multiplicacion

    

    opcion3:

    mov dx, offset num1

    call imprimir

    mov ah,1h

    int 21h

    

    sub al, 30h

    mov bl, al  

    

    mov dx, offset num2

    call imprimir

    mov ah,1h

    int 21h

    

    sub al, 30h  

    

    mul bl

    

    mov bl,al

    

    mov dx, offset result

    call imprimir

    

    add bl, 30h;

    

    mov ah, 2h

    mov dl, bl

    int 21h

    

    jmp mostrarmenu 

    

    ;Bloque de division

     

    opcion4:

    mov dx, offset num1

    call imprimir

    mov ah,1h

    int 21h

    

    mov dx, offset num2

    call imprimir

    mov ah,1h

    int 21h

    mov dx, offset result

    call imprimir

    jmp mostrarmenu

     

    opcion5:

    mov dx, offset n1

    call imprimir

    mov dx, offset n2

    call imprimir

    mov dx, offset n3

    call imprimir

    ;jmp mostrarmenu

    call finalizar

    

    


    imprimir: 

    mov ah, 09h

    int 21h

    ret

    

    finalizar:

    mov ax, 4ch

    int 21h  

    

   

    

    

    

    


    

end programa

Comentarios