I wanted to make a function which will print on the screen an array called sol. The distance between each char should be located 3 "chars" from ech other.
But , when I run my code only the first line of the array is printed.
Here is my Dseg code:
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.
But it is not the case. This instruction, actually use the address_of_temp+si. The content of [temp] is not used.
Here I would suggest to use only si as a pointer and think about other comparisons about loop end.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.