1

我正在开发一个可以绘制随机形状的 nasm 程序。我从这段代码开始,但每次编译时,我都会收到错误

bresen.asm:8:错误:操作数 1 后应有逗号

这是代码::

segment stack stack
        resb 100 ;declares a stack segment containing 64 bytes of uninitialised stack space, and points stacktop at the top
stacktop:

        segment data

        dex dw 0
        dy dw 0
        x_add dw 0
        y_add dw 0
        maxd dw 0
        act_dx dw 0
        act_dy dw 0
        c dw 0
        x1 dw 0
        y1 dw 0
        x2 dw 0
        y2 dw 0

        segment code
start:
        mov ax,data
        mov ds,ax
        mov ax,stack
        mov ss,ax
        mov sp,stacktop
          mov bp,stacktop

        ;init finished

        mov ah,0h
        mov al,13h
        int 10h

        ;screen set

        mov ax,word 200
        push ax          ;y2
        mov ax,word 50
        push ax          ;x2
        mov ax,word 20
        push ax          ;y1
        mov ax,word 65
        push ax          ;x1
        call line

        ;line(x1,y1,x2,y2)

        xor ax,ax
        int 16h

        ;wait key

        mov ah,0
        mov al,3
        int 10h

        ;go back to text mode

        mov ah,4ch
        int 21h

        ;end

line:
        push bp
        mov bp,sp
        mov ax,[bp+4] ;<-1 here
        mov [y2],ax
        mov ax,[bp+6]
        mov [x2],ax
        mov ax,[bp+8]
        mov [y1],ax
        mov ax,[bp+10]
        mov [x1],ax

        ;init-line end here!!!

        mov ax,[x2]
        sub ax,[x1]
        cmp ax,0
        jnl abs1
        neg ax
abs1:   mov [dex],ax

        ;dex=abs(x2-x1)

        mov ax,[y2]
        sub ax,[y1]
        cmp ax,0
        jnl abs2
        neg ax
abs2:   mov [dy],ax

        ;dy=abs(y2-y1)

        mov ax,[x1]
        cmp ax,[x2]
        jl min
        mov [x_add],word -1
        jmp end
min:    mov [x_add],word 1
end:
        ;if (x1>x2)

        mov ax,[y1]
        cmp ax,[y2]
        jl min2
        mov [y_add],word -1
        jmp end2
min2:   mov [y_add],word 1
end2:
        ;if (y1>y2)

        mov ax,[dy]
        cmp ax,[dex]
        jl min3
        mov ax,[dy]
        mov [maxd],ax
        jmp end3
min3:   mov ax,[dex]
        mov [maxd],ax
end3:

        mov cx,[maxd]
here:   mov ax,[dy]
        add [act_dy],ax
        mov ax,[act_dy]
        cmp ax,[maxd]
        jl next
        mov ax,[maxd]
        sub [act_dy],ax
        mov ax,[y_add]
        add [y1],ax
next:   mov ax,[dex]
        add [act_dx],ax
        mov ax,[act_dx]
        cmp ax,[maxd]
        jl next2
        mov ax,[maxd]
        sub [act_dx],ax
        mov ax,[x_add]
        add [x1],ax
next2:  call plot
        loop here
        mov sp,bp
        pop bp
        ret 8

plot:
        push ax
        push bx
        push cx
        push dx
        mov ah,0ch
        mov dx,[y1]
        mov cx,[x1]
        mov al,0d0h     ;change this to change the point-color
        mov bh,0h
        int 10h
        pop dx
        pop cx
        pop bx
        pop ax
        ret 

我试图找出原因,但它让我停滞了很长时间。我将不胜感激任何反馈或疑问。

4

1 回答 1

1

DY是 NASM 语法中的指令,因此不能将其用作符号名称。

于 2013-11-12T12:53:47.207 回答