Assembly 在emu8086&;中打印在屏幕上移动的ascii字符;删除字符
对于assembly和emu8086来说,这是一个相当新的概念,我正在尝试使用ASCII字符(星号*)从某个点开始在屏幕上以不同的方向移动 我可以让星号向右移动(请参阅代码段),但如何让它向左移动呢?上,下Assembly 在emu8086&;中打印在屏幕上移动的ascii字符;删除字符,assembly,emu8086,Assembly,Emu8086,对于assembly和emu8086来说,这是一个相当新的概念,我正在尝试使用ASCII字符(星号*)从某个点开始在屏幕上以不同的方向移动 我可以让星号向右移动(请参阅代码段),但如何让它向左移动呢?上,下 mov ah,downCol ; set cursor position mov bh,downRow mov dl, downCol ; change column mov dh, downRow ; change row mov
mov ah,downCol ; set cursor position
mov bh,downRow
mov dl, downCol ; change column
mov dh, downRow ; change row
mov cx, 20
loop1:
mov ah, 2
mov dl, 2ah ;*
int 21h
;mov dl, 20h ;space
;int 21h
;mov dl, 08h
;int 21h
loop loop1
另外,我一直在考虑在*输出后不久删除它,使它看起来像是在移动,但正如您在评论部分所看到的,它不起作用。我该怎么办
另外,我一直在考虑在*输出后不久删除它,使它看起来像是在移动,但正如您在评论部分所看到的,它不起作用
;mov dl, 20h ;space
;int 21h
;mov dl, 08h
;int 21h
如果您先输出退格(8),然后再输出空格(32),这就接近成功
我试图让一个ASCII字符(星号*)从某个点开始在屏幕上以不同的方向移动 执行这些操作的程序遵循以下步骤:
- 定位光标
- 画星号
- 稍等
- 通过画一个空格来删除星号
- 修改列或行(或两者都修改!)
- 从顶部重复
Top:
mov dh, Row
mov dl, Column
mov bh, 0
mov ah, 02h ;SetCursor
int 10h
mov cx, 1
mov bh, 0
mov al, "*"
mov ah, 0Ah ;DrawCharacter
int 10h
mov dx, 0 ;Approximately 1/8 second
mov cx, 2
mov ah, 86h ;Delay
int 15h
mov cx, 1
mov bh, 0
mov al, " "
mov ah, 0Ah ;DrawCharacter
int 10h
mov al, Sense ;Is +1 to go right, is -1 to go left
test al, al
js GoLeft
GoRight:
inc Column
cmp Column, 80
jb Top
mov Column, 78
neg Sense
jmp Top
GoLeft:
dec Column
jns Top
mov Column, 1
neg Sense
jmp Top
Column db 20
Row db 12
Sense db -1
这会让你对如何解决这个问题有一个想法
- 也许你可以引入两个方向变量SenseX和SenseY
- 也许你可以让用户决定应该是什么方向
B800:0000开始,除非您更改它):(而且它比BIOS快得多,在你的情况下会适得其反,因为你很难使移动速度足够慢:D…但是单星号即使在BIOS调用中也会太快)。
Top:
mov dh, Row
mov dl, Column
mov bh, 0
mov ah, 02h ;SetCursor
int 10h
mov cx, 1
mov bh, 0
mov al, "*"
mov ah, 0Ah ;DrawCharacter
int 10h
mov dx, 0 ;Approximately 1/8 second
mov cx, 2
mov ah, 86h ;Delay
int 15h
mov cx, 1
mov bh, 0
mov al, " "
mov ah, 0Ah ;DrawCharacter
int 10h
mov al, Sense ;Is +1 to go right, is -1 to go left
test al, al
js GoLeft
GoRight:
inc Column
cmp Column, 80
jb Top
mov Column, 78
neg Sense
jmp Top
GoLeft:
dec Column
jns Top
mov Column, 1
neg Sense
jmp Top
Column db 20
Row db 12
Sense db -1