assembly - 如何在特定列打印包含多行的整个字符串?
问题描述
这是我的代码:
data segment
letter_a db ' __ _ ',10,13
db ' / _` | ',10,13
db '| (_| | ',10,13
db ' \__,_| ',10,13
db ' '
opening_end db 0
pointer db 10
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
mov ax, data
mov ds, ax
mov es, ax
call print_opening
; wait for any key....
mov ah, 1
int 21h
call print_opening
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
ends
proc print_opening
pusha
mov al, 1
mov bh, 0
mov bl, 3
; I calculate length
lea cx, opening_end
lea dx, letter_a
sub cx, dx
mov dh, 3 ; row
mov dl, [pointer] ; col
lea bp, letter_a
mov ah, 13h
int 10h
mov ah, 8
int 21h
add [pointer], 10
popa
ret
endp print_opening
end start
问题是它只在我选择的列中开始字符串的第一行,然后返回到第 0 列。有没有办法随时缩进整个字符串?
我希望能够像在代码中一样更改它,而不仅仅是在数据段中设置缩进。
我真的希望这是可能的。提前致谢!
解决方案
鉴于需要一个循环来完成此操作,因此在数据行中使用换行和回车是没有用的。
letter_a db ' __ _ '
db ' / _` | '
db '| (_| | '
db ' \__,_| '
db ' '
opening_end db 0
pointer db 10
一旦在opening_end读取终止的 0,循环就会结束。
mov cx, 8 ; Every row has 8 characters
mov dh, 3 ; row on the screen to start
mov dl, [pointer] ; col on the screen is fixed
lea bp, letter_a
Again:
mov bx, 0003h ; display page 0 and attribute 03h
mov ax, 1301h ; function 13h and write mode 1
int 10h
add bp, cx ; To next line in the data
inc dh ; To next row on the screen
cmp [es:bp], ch ; CH=0
jne Again
推荐阅读
- c# - WPF - 如何用正方形填充窗口
- javascript - 在数组中查找和替换匹配的对象 - JavaScript
- r - 如何更正包裹(邮政编码)随附的数据框中的值并使其保持不变?
- perl - 在这个 perl 代码中 -> 意味着什么?
- javascript - groupBy/根据元素和类别的顺序减少一个数组
- c# - 将动态 Formflow 值传递回 Luis
- azure-language-understanding - 处理 LUIS 中的动词时态
- vim - 为什么我安装的插件 'gruvbox' 不显示?
- amazon-web-services - AWS SNS 编辑主题策略 - C#
- android - 在指定时间后清除 SharedPreference 数据