几周前我开始学习汇编,我编写了这个程序来获取用户输入。我挂断了,因为在我声明 msgOut 后程序冻结了 dos 框。但是,如果我将它与打印出来的代码一起注释掉,它会正常工作。任何帮助,将不胜感激。
; This program gets a character from the user and prints it out
org 100h ; program start point
section .data
msgIn: DB "Enter a character: $"
msgOut: DB 13, 10, "Character value: $"
section .bss
char resb 1 ; storage for input character
section .txt
; print enter message
mov dx, msgIn ; offset address of message to display
mov ah, 9 ; print string function
int 21h
; get user input
mov ah, 1 ; keyboard input sub-program
int 21h ; read character into al
; store character in char variable
mov [char], al ; move entered char into char variable
; print second message
mov dx, msgOut ; offset of second message
mov ah, 9 ; print string function
int 21h ; display message
; display character
mov dl, [char] ; char to display
mov ah, 2 ; print char function
int 21h
; exit program
mov ah, 4ch ; exit to DOS function
int 21h ; see you later!