如何在汇编emu8086中输入2位数字

时间:2016-10-15 14:13:31

标签: assembly emu8086

mov ah,01h
int 21h

我知道这是你输入一位数字或字符的方式,但我怎样才能输入数字38。 谢谢

3 个答案:

答案 0 :(得分:1)

这应该适合你:

.model small
.data
.code

    mov ax, @data
    mov ds, ax 

    mov dl, 10  
    mov bl, 0         

    scanNum:

            mov ah, 01h
            int 21h

            cmp al, 13   ; Check if user pressed ENTER KEY
            je  exit 

            mov ah, 0  
            sub al, 48   ; ASCII to DECIMAL

            mov cl, al
            mov al, bl   ; Store the previous value in AL

            mul dl       ; multiply the previous value with 10

            add al, cl   ; previous value + new value ( after previous value is multiplyed with 10 )
            mov bl, al

            jmp scanNum    

    exit:

           mov ah, 04ch   
           int 21h

end

答案 1 :(得分:-1)

.model small      
.stack 100h     
.data      
.code          
main proc         
mov ah, 1    
int 21h     
mov bl,al    
mov al, 1    
int 21h     
add bl,al    
sub bl, 48    
mov dl,bl    
mov ah, 2    
int 21h    
mov ah, 4ch    
int 21h    
main endp    
end main    

答案 2 :(得分:-2)

library(magrittr)

melt.data.frame(ChickWeight, measure.vars = 'weight', na.rm=TRUE) %>%
   dplyr::filter(Diet %in% c(1, 4) & Time == 21)