我正在学习汇编,我正在尝试使用BIOS调用从键盘/打印到键盘进行简单的读取.到目前为止,我有以下内容:
loop:
xor ah, ah
int 0x16 ; wait for a charater
mov ah, 0x0e
int 0x10 ; write character
jmp loop
Run Code Online (Sandbox Code Playgroud)
这个工作正常,直到有人按下回车键 - 似乎正在处理CR(\ r)而不是换行符(\n),因为光标移动到当前行的开头,而不是下一行的开头线.
有任何想法吗?
中断0x16,函数0x00仅为AL中的Enter键(CR,0x0D)返回一个ASCII字符,对中断0x10的调用,函数0x0E将打印此单个ASCII字符.如果您希望代码也吐出LF,则必须测试CR并强制LF输出.
loop:
xor ah, ah
int 0x16 ; wait for a charater
mov ah, 0x0e
int 0x10 ; write character
cmp al, 0x0d ; compare to CR
jne not_cr ; jump if not a CR
mov al, 0x0a ; load the LF code into al
int 0x10 ; output the LF
not_cr:
jmp loop
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3015 次 |
| 最近记录: |