Assembly 重复组装8086中的说明

Assembly 重复组装8086中的说明,assembly,x86-16,Assembly,X86 16,我已经创建了3个看起来很好看的正方形。我只想一遍又一遍地重复这个动画,我知道这并不难,但我找不到如何做到这一点。解释是用罗马尼亚语写的,对不起 基本上我只想清除屏幕,让它们一遍又一遍地出现。谢谢大家的支持 .stack 100 .data y1 dw 70 x dw 70 y2 dw 120 x2 dw 130 y3 dw 70 y4 dw 120 x3 dw 190 y5 dw 70 y6 dw 120 l db 50; lungime k db 50;latime kfinal db

我已经创建了3个看起来很好看的正方形。我只想一遍又一遍地重复这个动画,我知道这并不难,但我找不到如何做到这一点。解释是用罗马尼亚语写的,对不起

基本上我只想清除屏幕,让它们一遍又一遍地出现。谢谢大家的支持

.stack 100
.data
y1 dw 70
x  dw 70
y2 dw 120

x2 dw 130
y3 dw 70
y4 dw 120

x3 dw 190
y5 dw 70
y6 dw 120

l db 50; lungime
k db 50;latime
kfinal db 51
n db 50

.code
mov ax,@data
mov ds,ax
mov ah,0h
mov al,13h; comutare in modul grafic 13h (320 x 200)
int 10h

desen:
mov dx,y1
mov cx,x
mov al,1; culoare
mov bl,l; lungime linie
mov ah,0ch; scriere pixel, cu culoare in al, cx=x, dx=y
mov bh,0
ciclu1: int 10h ; aprindere pixel de coordonate (cx,dx)
push dx
mov dx,y2
call delay
call delay
call delay
call delay
int 10h
pop dx
inc cx
dec bl
jnz ciclu1
mov bl,k; latime

ciclu2: int 10h ; aprinde pixel de coord (cx,dx)
push cx
mov cx,x
call delay
call delay
call delay
call delay
int 10h
pop cx
inc dx
dec bl
jnz ciclu2
int 10h
mov dx,y3
mov cx,x2
mov al,14; culoare
mov bl,l; lungime linie
mov ah,0ch; scriere pixel, cu culoare in al, cx=x, dx=y
mov bh,0

ciclu3: int 10h ; aprindere pixel de coordonate (cx,dx)
push dx
mov dx,y4
call delay
call delay
call delay
call delay
int 10h
pop dx
inc cx
dec bl
jnz ciclu3
mov bl,k; latime
ciclu4: int 10h ; aprinde pixel de coord (cx,dx)
push cx
mov cx,x2
call delay
call delay
call delay
call delay
int 10h
pop cx
inc dx
dec bl
jnz ciclu4
int 10h
mov dx,y5
mov cx,x3
mov al,4; culoare
mov bl,l; lungime linie
mov ah,0ch; scriere pixel, cu culoare in al, cx=x, dx=y
mov bh,0

ciclu5: int 10h ; aprindere pixel de coordonate (cx,dx)
push dx
mov dx,y6
call delay
call delay
call delay
call delay
int 10h
pop dx
inc cx
dec bl
jnz ciclu5
mov bl,kfinal; latime ultimul patratel

ciclu6: int 10h ; aprinde pixel de coord (cx,dx)
push cx
mov cx,x3
call delay
call delay
call delay
call delay
int 10h
pop cx
inc dx
dec bl
jnz ciclu6
ret

delay:
push cx
mov cx, 0ffffh
et1: dec cx
jnz et1
pop cx
ret


mov ah,4ch
int 21h
end


一些重要的观察结果
  • 首先让我印象深刻的是,您没有为程序变量使用描述性名称,这使问题变得复杂!请参阅下面的一些更好的名称

  • 虽然您已将宽度和高度都设置为50(
    l db 50;lungime
    k db 50;latime
    ),但您绘制的长方体的曲面为51x51

  • 在绘制最终的下角点时,第一个(蓝色)框和第二个(黄色)框使用与第三个(红色)框不同的系统。为什么呢? 为什么要使用额外变量
    kfinal db 51

  • 绘制框的代码以
    ret
    指令结束,但它不是
    调用
    -ed。这是错误的。此外,终止到DOS的代码是不可访问的,因为它位于另一条
    ret
    指令的下面

  • 不要将整个方框图代码重复3次,而应将其放入子例程中,并将其调用3次

        mov  al, 1        ; Blue
        mov  cx, Box1Left
        mov  dx, Box1Top
        mov  bp, Box1Bottom
        call DrawBox
        mov  al, 14       ; Yellow
        mov  cx, Box2Left
        mov  dx, Box2Top
        mov  bp, Box2Bottom
        call DrawBox
        mov  al, 4        ; Red
        mov  cx, Box2Left
        mov  dx, Box2Top
        mov  bp, Box2Bottom
        call DrawBox
    
        mov  ax, 4C00h    ; DOS.Terminate
        int  21h
    
    DrawBox:
        mov  ah, 0Ch      ; BIOS.WritePixel
        mov  bh, 0        ; DisplayPage
        push cx           ; (1)
    
        mov  bl, 50       ; Width = Length of the horizontal line
    ciclu1:
        int  10h
        xchg dx, bp
        int  10h
        xchg dx, bp
        inc  cx
        dec  bl
        jnz  ciclu1
    
        pop  bp           ; (1)
        mov  bl, 51       ; Height = Length of the vertical line
    ciclu2:
        int  10h
        xchg cx, bp
        int  10h
        xchg cx, bp
        inc  dx
        dec  bl
        jnz  ciclu2
        ret
    

你问题的答案是什么 基本上我只想清除屏幕,让它们一遍又一遍地出现

如果这就是你想要的,那么你只需要重新启动你的程序。您的程序已通过清除屏幕启动,因为它将视频模式设置为13h。
请给用户一个停止程序的机会。请参见下面的示例代码中我是如何做到这一点的:

    mov  ax, @data
    mov  ds, ax

Again:
    mov  ah, 00h
    mov  al, 13h; comutare in modul grafic 13h (320 x 200)
    int  10h

    ; Here you draw the boxes! Use the above code snippet...

    mov  ah, 00h      ; BIOS.WaitKey Wait for the user to press any key
    int  16h          ; -> AX
    cmp  al, 27       ; Did the user press <ESC> ?
    je   Exit         ; Yes
    jmp  Again        ; No, restart the program (this could be a big jump)

Exit:
    mov  ax, 4C00h    ; DOS.Terminate
    int  21h

; All subroutines go here, below the Exit to DOS!
mov-ax,@data
mov-ds,ax
再一次:
mov啊,00h
mov-al,13h;模数为13h的组件(320 x 200)
int 10h
; 给你画盒子!使用上面的代码段。。。
mov-ah,00h;BIOS.WaitKey等待用户按任意键
int 16h;->斧头
cmp-al,27;用户按了吗?
日本脑炎出口;对
jmp;不,重新启动程序(这可能是一个很大的飞跃)
出口:
mov-ax,4C00h;结束
int 21h
; 所有的子程序都在这里,在DOS出口下面!
你可以在这篇文章中阅读更多关于绘画的内容

一些重要的观察结果
  • 首先让我印象深刻的是,您没有为程序变量使用描述性名称,这使问题变得复杂!请参阅下面的一些更好的名称

  • 虽然您已将宽度和高度都设置为50(
    l db 50;lungime
    k db 50;latime
    ),但您绘制的长方体的曲面为51x51

  • 在绘制最终的下角点时,第一个(蓝色)框和第二个(黄色)框使用与第三个(红色)框不同的系统。为什么呢? 为什么要使用额外变量
    kfinal db 51

  • 绘制框的代码以
    ret
    指令结束,但它不是
    调用
    -ed。这是错误的。此外,终止到DOS的代码是不可访问的,因为它位于另一条
    ret
    指令的下面

  • 不要将整个方框图代码重复3次,而应将其放入子例程中,并将其调用3次

        mov  al, 1        ; Blue
        mov  cx, Box1Left
        mov  dx, Box1Top
        mov  bp, Box1Bottom
        call DrawBox
        mov  al, 14       ; Yellow
        mov  cx, Box2Left
        mov  dx, Box2Top
        mov  bp, Box2Bottom
        call DrawBox
        mov  al, 4        ; Red
        mov  cx, Box2Left
        mov  dx, Box2Top
        mov  bp, Box2Bottom
        call DrawBox
    
        mov  ax, 4C00h    ; DOS.Terminate
        int  21h
    
    DrawBox:
        mov  ah, 0Ch      ; BIOS.WritePixel
        mov  bh, 0        ; DisplayPage
        push cx           ; (1)
    
        mov  bl, 50       ; Width = Length of the horizontal line
    ciclu1:
        int  10h
        xchg dx, bp
        int  10h
        xchg dx, bp
        inc  cx
        dec  bl
        jnz  ciclu1
    
        pop  bp           ; (1)
        mov  bl, 51       ; Height = Length of the vertical line
    ciclu2:
        int  10h
        xchg cx, bp
        int  10h
        xchg cx, bp
        inc  dx
        dec  bl
        jnz  ciclu2
        ret
    

你问题的答案是什么 基本上我只想清除屏幕,让它们一遍又一遍地出现

如果这就是你想要的,那么你只需要重新启动你的程序。您的程序已通过清除屏幕启动,因为它将视频模式设置为13h。
请给用户一个停止程序的机会。请参见下面的示例代码中我是如何做到这一点的:

    mov  ax, @data
    mov  ds, ax

Again:
    mov  ah, 00h
    mov  al, 13h; comutare in modul grafic 13h (320 x 200)
    int  10h

    ; Here you draw the boxes! Use the above code snippet...

    mov  ah, 00h      ; BIOS.WaitKey Wait for the user to press any key
    int  16h          ; -> AX
    cmp  al, 27       ; Did the user press <ESC> ?
    je   Exit         ; Yes
    jmp  Again        ; No, restart the program (this could be a big jump)

Exit:
    mov  ax, 4C00h    ; DOS.Terminate
    int  21h

; All subroutines go here, below the Exit to DOS!
mov-ax,@data
mov-ds,ax
再一次:
mov啊,00h
mov-al,13h;模数为13h的组件(320 x 200)
int 10h
; 给你画盒子!使用上面的代码段。。。
mov-ah,00h;BIOS.WaitKey等待用户按任意键
int 16h;->斧头
cmp-al,27;用户按了吗?
日本脑炎出口;对
jmp;不,重新启动程序(这可能是一个很大的飞跃)
出口:
mov-ax,4C00h;结束
int 21h
; 所有的子程序都在这里,在DOS出口下面!
你可以在这篇文章中阅读更多关于绘画的内容