Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Sign in to follow this  
JoaoNascimento

Assembly 8086 Printf de valor

Recommended Posts

JoaoNascimento

Ola pessoal como faço o printf no ecrã em Assembly 8086:

O codigo é este

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

ORG 100H

JMP MAIN

NUM1 DB 12H
NUM2 DB 12H
RES DB ? 

MAIN:
LEA DX, OPCAO
CALL ESCREVA

mov ah, 7
int 21h

REPETE:
    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
    JNE REPETE

RET

SOMA:
    MOV AH, NUM1
    ADD AH, NUM2
    MOV RES, AH
    LEA DX, RES
    CALL ESCREVA
    
    
SUBT:
    MOV AH, NUM1
    SUB AH, NUM2
    MOV RES, AH
    LEA DX, RES
    CALL ESCREVA
    
MULT:
    MOV AH, NUM1
    MOV BH, NUM2
    MUL BH
    MOV RES, AH
    LEA DX, RES
    CALL ESCREVA
    
DIVI:
    MOV AH, NUM1
    MOV BH, NUM2
    DIV BH  
    MOV RES, AH
    LEA DX, RES
    CALL ESCREVA
    
SAIR:
    RET

;--------------------------------------------------------------------------------
ESCREVA PROC NEAR       ;PROCEDIEMENTO QUE ESCRVE NO ECRA
        
        MOV AH, 09H
        INT 21H 
    
    
        RET
;--------------------------------------------------------------------------------- 




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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.