Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Animation 试图在程序集8086中移动对象_Animation_Assembly_X86 16 - Fatal编程技术网

Animation 试图在程序集8086中移动对象

Animation 试图在程序集8086中移动对象,animation,assembly,x86-16,Animation,Assembly,X86 16,我想移动行中的一个字符(最初行=0),如果行是50,它将停止。但它没有按预期工作。 可能是由于lea dx和行值在dl中这一事实,它不起作用 dosseg .model small .stack 100h .data snake db ">$" .code main proc mov ax, @data mov ds, ax mov ah, 06h mov al, 0 mov ch, 0 mov cl, 0

我想移动行中的一个字符(最初行=0),如果行是50,它将停止。但它没有按预期工作。
可能是由于
lea dx
和行值在
dl
中这一事实,它不起作用

dosseg
.model small
.stack 100h

.data
    snake db ">$"
.code

main proc

     mov ax, @data
     mov ds, ax

     mov ah, 06h
     mov al, 0
     mov ch, 0
     mov cl, 0
     mov dh, 24
     mov dl, 79
     mov bh, 00001100b

     int 10h
     mov dl, 5

    lb1:
         mov ah, 02h
         mov bh, 0
         mov dh, 5


         int 10h
         inc dl

         lea dx, snake
         mov ah, 2
         int 21h

        cmp dl, 50

  jbe lb1

     mov ah, 4ch
     int 21h

main endp
end main

我想移动[initial row=0]行中的一个字符,如果该行是[row=50],它将停止

您是否知道您的程序更改了列而不是行


上述代码在
DL
中破坏您的列这一事实可以通过两种方式更正:

.在堆栈上保留
DL

push dx
lea  dx, snake
mov  ah, 09h
int  21h
pop  dx
.不要使用其他输出功能破坏
DL

mov  cx, 1
mov  bh, 0
mov  al, '>'
mov  ah, 0Ah
int  10h

要获得移动的感觉,需要将对象移到其原来的位置:

lb1:
 mov  cx, 1
 mov  bh, 0
 mov  al, ' '   ;Remove at old place
 mov  ah, 0Ah
 int  10h

 inc  dl        ;Goto to new place (next column)
 mov  dh, 5     ;Row 5, Column in DL
 mov  bh, 0
 mov  ah, 02h
 int  10h

 mov  cx, 1
 mov  bh, 0
 mov  al, '>'   ;Show at new place
 mov  ah, 0Ah
 int  10h

 cmp  dl, 50
 jbe  lb1
因为一切都会发生得如此之快,你根本看不到运动!显示对象后需要暂停

作为快速替代,我将使用等待击键:

lb1:
 mov  cx, 1
 mov  bh, 0
 mov  al, ' '   ;Remove at old place
 mov  ah, 0Ah
 int  10h

 inc  dl        ;Goto to new place (next column)
 mov  dh, 5     ;Row 5, Column in DL
 mov  bh, 0
 mov  ah, 02h
 int  10h

 mov  cx, 1
 mov  bh, 0
 mov  al, '>'   ;Show at new place
 mov  ah, 0Ah
 int  10h

 mov  ah, 00h   ;Wait for a keystroke.
 int  16h

 cmp  dl, 50
 jbe  lb1

lea dx,snake
感谢@Michael的重播,我做了一些更改,至少它起作用了。但是我在我的问题上做了一些改变,请看这个。抱歉耽误了你的时间我是新来的assembly@michael我想在屏幕上移动-->但它改变了它的位置,移动了--25次。我只想移动-->然后你必须在旧位置写一个空格字符(
'
)。如果是新的,你能告诉我如何移动-->或任何博客或参考吗?
lb1:
 mov  cx, 1
 mov  bh, 0
 mov  al, ' '   ;Remove at old place
 mov  ah, 0Ah
 int  10h

 inc  dl        ;Goto to new place (next column)
 mov  dh, 5     ;Row 5, Column in DL
 mov  bh, 0
 mov  ah, 02h
 int  10h

 mov  cx, 1
 mov  bh, 0
 mov  al, '>'   ;Show at new place
 mov  ah, 0Ah
 int  10h

 mov  ah, 00h   ;Wait for a keystroke.
 int  16h

 cmp  dl, 50
 jbe  lb1