需要有关汇编器视频模式的帮助

发布于 2024-10-30 17:41:10 字数 1549 浏览 1 评论 0原文

我正在为我的班级做一些编码,我认为我走在正确的轨道上,但我遇到了垂直线的问题。当我运行此代码时,它会在同一位置同时水平绘制 2 条线,但我需要第 2 条线从 50,50 垂直移动到 50,75,而不是水平从 50, 50 移动到 75,50。我不是在寻求答案,我只是需要一个推动和解释,谢谢:

; video.asm
; uses interrupts to set video mode and draw a line

include 'emu8086.inc'

org  100h ; set location counter to 100h

jmp CodeStart

DataStart:
    xStart1 dw 50        ; x coordinate of line start 1
    yStart1 dw 50        ; y coordinate of line start 1
    xStart2 dw 50        ; x coordinate of line start 2
    yStart2 dw 50        ; y coordinate of line start 2
    length dw 25        ; length of line

CodeStart:

    ; set the video mode 320x200, 256 colors
    mov al, 13h
    mov ah, 0
    int 10h

    ; initialize cx (x coord) to xStart1 + length
    ; initialize bx (y coord) to yStart2 + length
    mov cx, xStart1
    mov bx, yStart2
    add cx, length
    add bx, length


    ; loop from (xStart1+length) to xStart1 to draw a horizontal line
    ; loop from (yStart1+length) to yStart1 to draw a vertical line
    LoopStart:    

        ; draw a pixel
        ; set color in al, x in cx, y in dx
        mov al, 50
        mov dx, yStart1

        ; set sub function value in ah to draw a pixel
        ; and invoke the interrupt
        mov ah, 0ch
        int 10h

        ; decrement the x coord for line 1
        ; decrement the y coord for line 2
        sub cx, 1
        sub bx, 1

        ; test to see if x coord has reached start value
        cmp cx, xStart1

    ; continue loop if cx >= xStart1
    jae LoopStart

    ret

I am doing some coding for my class and I think I am on the right track but I am having a problem with verticle lines. When I run this code it draws 2 lines horizontal at the same time in the same exact place but I need line 2 to move from 50,50 to 50,75 vertically instead of from 50, 50 to 75,50 horizontally. I am not asking for the answer I just need a nudge and explanation, thanks:

; video.asm
; uses interrupts to set video mode and draw a line

include 'emu8086.inc'

org  100h ; set location counter to 100h

jmp CodeStart

DataStart:
    xStart1 dw 50        ; x coordinate of line start 1
    yStart1 dw 50        ; y coordinate of line start 1
    xStart2 dw 50        ; x coordinate of line start 2
    yStart2 dw 50        ; y coordinate of line start 2
    length dw 25        ; length of line

CodeStart:

    ; set the video mode 320x200, 256 colors
    mov al, 13h
    mov ah, 0
    int 10h

    ; initialize cx (x coord) to xStart1 + length
    ; initialize bx (y coord) to yStart2 + length
    mov cx, xStart1
    mov bx, yStart2
    add cx, length
    add bx, length


    ; loop from (xStart1+length) to xStart1 to draw a horizontal line
    ; loop from (yStart1+length) to yStart1 to draw a vertical line
    LoopStart:    

        ; draw a pixel
        ; set color in al, x in cx, y in dx
        mov al, 50
        mov dx, yStart1

        ; set sub function value in ah to draw a pixel
        ; and invoke the interrupt
        mov ah, 0ch
        int 10h

        ; decrement the x coord for line 1
        ; decrement the y coord for line 2
        sub cx, 1
        sub bx, 1

        ; test to see if x coord has reached start value
        cmp cx, xStart1

    ; continue loop if cx >= xStart1
    jae LoopStart

    ret

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

面如桃花 2024-11-06 17:41:10

不要保持 y 不变并改变 x,而是保持 x 不变并改变 y

Instead of keeping y constant and varying x, keep x constant and vary y

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文