x86-16 - Emu8086 - 尝试向下移动光标时光标位置不正确
问题描述
我正在测试使用emu8086将文本写入屏幕。我正在尝试打印带有字母 A 到 I 的 3x3 网格。我想这不是向下移动光标(执行回车)的传统方法,但它应该可以工作。
org 100h
;
; Initialise
;
; Set video mode
mov AL, 13h
mov AH, 0
int 10h
; Set cursor position
mov DH, 1
mov DL, 1
mov BH, 0
mov AH, 2
int 10h
; Set cursor intensity/blinking
mov ax, 1003h
mov bx, 0
int 10h
; Set attribute to white foreground, black background
mov BL, 0Fh
call print_grid
jmp end
print_char PROC
mov AH, 09h ; Set interrupt to print
mov CX, 1 ; So that the character is only printed once
int 10h
inc DL ; Incrementing the cursor position horizontally
mov AH, 2h ; Set interrupt to set cursor position
int 10h
ret
print_char ENDP
carriage_return PROC
inc DH ; Incrementing the cursor position vertically
mov DL, 1 ; Resetting horizontal cursor position
mov AH, 2h ; Set interrupt to set cursor position
int 10h
ret
carriage_return ENDP
; Prints the grid to the screen
print_grid PROC
; Row 1
mov AL, pos[0]
call print_char
mov AL, '|'
call print_char
mov AL, pos[1]
call print_char
mov AL, '|'
call print_char
mov AL, pos[2]
call print_char
call carriage_return
; Row 2
mov AL, '-'
call print_char
mov AL, '+'
call print_char
mov AL, '-'
call print_char
mov AL, '+'
call print_char
mov AL, '-'
call print_char
call carriage_return
; Row 3
mov AL, pos[3]
call print_char
mov AL, '|'
call print_char
mov AL, pos[4]
call print_char
mov AL, '|'
call print_char
mov AL, pos[5]
call print_char
call carriage_return
; Row 4
mov AL, '-'
call print_char
mov AL, '+'
call print_char
mov AL, '-'
call print_char
mov AL, '+'
call print_char
mov AL, '-'
call print_char
call carriage_return
; Row 5
mov AL, pos[6]
call print_char
mov AL, '|'
call print_char
mov AL, pos[7]
call print_char
mov AL, '|'
call print_char
mov AL, pos[8]
call print_char
call carriage_return
ret
print_grid ENDP
end:
ret
pos DB 65, 66, 67, 68, 69, 70, 71, 72, 73
虚拟屏幕上出现的是这个
我知道有更好的方法可以使用 emu8086 打印字符,例如 PRINT/PRINTN 宏,但我想尝试手动进行,所以我希望能回答为什么程序输出这个。尽管如果您愿意,欢迎使用有关改进此代码的一般提示。
解决方案
推荐阅读
- javascript - 在 Rails 控制器中解析 HTML 请求的响应标头
- laravel - 图片未显示在首页
- regex - 如何从 Python 中的字典中删除 unigram
- laravel - laravel 中的求和收集
- python - 在 Raspberry Pi 上使用超声波测距模块控制继电器模块
- oauth-2.0 - 为什么不能在后端使用 jwt id 令牌进行身份验证?
- android - 观察本地对象更改的 LiveData 属性
- python - 如何计算第二大值并在 Pandas Python 中为其添加另一列
- azure - 为什么 Cassandra 迁移到 Cosmos 后数据量会增加?
- javascript - 使用正则表达式提取单词,除非它是给定的单词