简体   繁体   English

为什么我的功能不起作用? (部件)

[英]Why my function doesn't work? (Assembly)

I wanted to make a function which will print on the screen an array called sol. 我想制作一个函数,该函数将在屏幕上打印一个名为sol的数组。 The distance between each char should be located 3 "chars" from ech other. 每个字符之间的距离应位于3个“字符”之间。
But , when I run my code only the first line of the array is printed. 但是 ,当我运行代码时,仅打印数组的第一行。

Here is my Dseg code: 这是我的Dseg代码:

line db 0
col db 0
temp db 3
indexc dw 0
sol db   'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'
S_LEN = $- sol
            db   'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'
            db   '*', '*', '*', '*', '*', '*', '*', '*'
            db   '*', '*', '*', '*', '*', '*', '*', '*'
            db   '*', '*', '*', '*', '*', '*', '*', '*'
            db   '*', '*', '*', '*', '*', '*', '*', '*'
            db   'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'
            db   'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'
S_LEN2 = $- sol

my function is: 我的功能是:

 PutPlayers Proc    
    push ax bx cx dx si

InitiolazingVar:

    mov temp, offset sol
    mov line, 1
    mov col, 1
    mov si, 1
Again:  
    ;location 
        mov dl, col
        mov dh, line
        mov bx, 0
        mov ah, 2h
        int 10h



    ;printing the char
        mov al, ds:[temp][si]
        mov bl, 33
        mov cx, 1h
        mov bh, 0
        mov ah, 9h
        int 10h

        add col, 3h
        inc si
        cmp si, 9
        jnz Again


        add temp, S_LEN
        mov si, 1h
        mov col, 1h
        add line, 3h

        cmp line, 19h
        jnz Again

        pop si dx cx bx ax
        ret
PutPlayers endp 

So, can you please help me? 所以,能请你帮我吗?

At first glance, I don't like the instruction: 乍一看,我不喜欢这样的指示:

mov al, ds:[temp][si]

I think you are expecting that it will read a byte from the address equal to the sum of content of [temp] and the content of SI. 我想你期待它会读取地址等于[临时]和SI的内容的内容之和的字节。

But it is not the case. 但事实并非如此。 This instruction, actually use the address_of_temp+si. 该指令实际上使用了address_of_temp + si。 The content of [temp] is not used. 不使用[temp]的内容。

Here I would suggest to use only si as a pointer and think about other comparisons about loop end. 在这里,我建议仅使用si作为指针,并考虑其他有关循环结束的比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM