joaonascimento 0 Newbie Poster

Hi!

I have this program:

include emu8086.inc

name "CALC"   ; output file name (max 8 chars for DOS compatibility)

ORG 100H

JMP MAIN

A DW ?
B DW ?     
X DW 0, '$'
Y DB 0, '$' 

MAIN:
LEA DX, OPCAO
CALL ESCREVA 
CALL LER



MENU1:     
    
    CMP AL,'1'
    JE SOMA
    CMP AL,'2'
    JE SUBT
    CMP AL,'3'
    JE MULT
    CMP AL,'4'
    JE DIVI
    CMP AL,'5'
    JE SAIR 
    
    
REPETIR:

    CALL LIMPA    
    LEA DX, OPCAO2
    CALL ESCREVA
    CALL LER 
    
    CMP AL, '1'
    JE MENU1
    
    
ATE: 
    CMP AL, '2'
    JE SAIR
    JNE REPETIR

RET

SOMA:     
    CALL LIMPA  
    CALL CALCULADORA
    GOTOXY 1,3
    
    CALL DIGITO1
    MOV AX, A
    
    GOTOXY 1,3
    CALL DIGITO2
    ADD AX, B
    
    GOTOXY 1,3
    MOV X, AX
    ADD X, 030H
    MOV DX, OFFSET X
    CALL ESCREVA
    CALL PARAR 
    JMP REPETIR
    
    RET
    
    
SUBT:
    CALL LIMPA 
    CALL CALCULADORA
    GOTOXY 1,3
    
    
    MOV AX, A 

    SUB AX, B

    MOV X, AX
    ADD X, 030H
    MOV DX, OFFSET X
    CALL ESCREVA
    CALL PARAR
    JMP REPETIR 
    
    RET
    
MULT:
    CALL LIMPA  
    CALL CALCULADORA
    GOTOXY 1,3
    MOV AX, A
    MOV BX, B  

    MUL BX

    MOV X, AX
    ADD X, 030H
    MOV DX, OFFSET X
    CALL ESCREVA 
    CALL PARAR
    JMP REPETIR
    
    RET
    
DIVI: ;VER PORQUE ESTA MAL , 
    CALL LIMPA  
    CALL CALCULADORA
    GOTOXY 1,3
    mov ax, a
    mov bx, b
    
    div bx
    
    mov y, al
    
    add y, 030h
    mov dx, offset y
    CALL ESCREVA
    CALL PARAR
    JMP REPETIR  
    
    RET
    
SAIR:
    RET

;--------------------------------------------------------------------------------
ESCREVA PROC NEAR       ;PROCEDIMENTO QUE ESCRVE NO ECRA
        
        MOV AH, 09H
        INT 21H 
    
    
        RET
;--------------------------------------------------------------------------------- 
LIMPA   PROC NEAR       ;PROCEDIMENTO QUE LIMPA O ECRA
        
        MOV AH, 00H
        MOV AL, 03H
        INT 10H 
    
        RET
;--------------------------------------------------------------------------------
LER PROC NEAR       ;PROCEDIMENTO QUE ESCRVE NO ECRA 
        
        MOV AH, 07H
        INT 21H 
    
    
        RET
;--------------------------------------------------------------------------------- 
CALCULADORA PROC NEAR
        
    lea dx, calc1
    call escreva
    lea dx, calc2
    call escreva
    lea dx, calc3
    call escreva
    lea dx, calc4
    call escreva
    lea dx, calc5
    call escreva
    lea dx, calc6
    call escreva
    lea dx, calc7
    call escreva
    lea dx, calc8
    call escreva
    lea dx, calc9
    call escreva
    lea dx, calc10
    call escreva
    lea dx, calc11
    call escreva
    lea dx, calc12
    call escreva
    lea dx, calc13
    call escreva
    lea dx, calc14
    call escreva
    lea dx, calc15
    call escreva
    lea dx, calc16
    call escreva
    lea dx, calc17
    call escreva
    lea dx, calc18
    call escreva
    lea dx, calc19
    call escreva
    lea dx, calc20
    call escreva
    lea dx, calc21
    call escreva
    lea dx, calc22
    CALL ESCREVA
    
    RET
;---------------------------------------------------------------------------------
PARAR   PROC NEAR       ;PROCEDIMENTO PARA TRAVAR O ECRA E ESPERA QUE SEJA DIGITALIZADA UMA TECLA  
        
        MOV AH, 1H
	    INT 21H  
	    
        RET
;---------------------------------------------------------------------------------
SCAN_NUM        PROC    NEAR
        PUSH    DX
        PUSH    AX
        PUSH    SI
        
        MOV     CX, 0

        ; reset flag:
        ;MOV     CS:make_minus, 0
;---------------------------------------------------------------------------------
DIGITO1         PROC    NEAR
        
        ;RECEBE DO TECLADO UM VALOR
        MOV     AH, 00h
        INT     16h
        ;IMPRIME NO ECRA O VALOR
        MOV     AH, 0Eh
        INT     10h 
        
        MOV A, AX
                                
        RET                        
;--------------------------------------------------------------------------------- 
DIGITO2         PROC    NEAR
        
        ;RECEBE DO TECLADO UM VALOR
        MOV     AH, 00h
        INT     16h
        ;IMPRIME NO ECRA O VALOR
        MOV     AH, 0Eh
        INT     10h 
        
        MOV B, AX
                                
        RET                        
;---------------------------------------------------------------------------------

NUM1 DB 'INSIRA O PRIMEIRO NUMERO',13,10,'$'
NUM2 DB 'INSIRA O SEGUNDO  NUMERO',13,10,'$'

opcao db  '1-Soma/2-Subt/3-Mult/4-Divi/5-Sair :$',0DH, 0AH, 024h

OPCAO2 DB 'DESEJA FAZER OUTRO CALCULO: 1)SIM; 2)NAO;',13,10,'$' 

CALC1 DB  '--------------------------',13,10,'$',0DH, 0AH, 024h
CALC2 DB  '|CALCULADORA             |',13,10,'$',0DH, 0AH, 024h
CALC3 DB  '--------------------------',13,10,'$',0DH, 0AH, 024h
CALC4 DB  '|                        |',13,10,'$',0DH, 0AH, 024h
CALC5 DB  '--------------------------',13,10,'$',0DH, 0AH, 024h
CALC6 DB  '| ---   ---   ---   ---  |',13,10,'$',0DH, 0AH, 024h
CALC7 DB  '||   | |   | |   | |   | |',13,10,'$',0DH, 0AH, 024h 
CALC8 DB  '|| 1 | | 2 | | 3 | | + | |',13,10,'$',0DH, 0AH, 024h
CALC9 DB  '| ---   ---   ---   ---  |',13,10,'$',0DH, 0AH, 024h
CALC10 DB '| ---   ---   ---   ---  |',13,10,'$',0DH, 0AH, 024h
CALC11 DB '||   | |   | |   | |   | |',13,10,'$',0DH, 0AH, 024h 
CALC12 DB '|| 4 | | 5 | | 6 | | - | |',13,10,'$',0DH, 0AH, 024h
CALC13 DB '| ---   ---   ---   ---  |',13,10,'$',0DH, 0AH, 024h
CALC14 DB '| ---   ---   ---   ---  |',13,10,'$',0DH, 0AH, 024h
CALC15 DB '||   | |   | |   | |   | |',13,10,'$',0DH, 0AH, 024h 
CALC16 DB '|| 7 | | 8 | | 9 | | * | |',13,10,'$',0DH, 0AH, 024h
CALC17 DB '| ---   ---   ---   ---  |',13,10,'$',0DH, 0AH, 024h
CALC18 DB '| ---   ---   ---   ---  |',13,10,'$',0DH, 0AH, 024h
CALC19 DB '||   | |   | |   | |   | |',13,10,'$',0DH, 0AH, 024h 
CALC20 DB '||   | | 0 | |   | | / | |',13,10,'$',0DH, 0AH, 024h
CALC21 DB '| ---   ---   ---   ---  |',13,10,'$',0DH, 0AH, 024h
CALC22 DB '--------------------------',13,10,'$',0DH, 0AH, 024h

And in the function 'soma' don´t make the calcutations correct.

For example, I have put in a 2 and in b 2, and the result is one weird character...

Please is very urgent...

PS.I have not tried the others funcion (subt, mult, divi)....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.