[英]Why my function doesn't work? (Assembly)
我想制作一個函數,該函數將在屏幕上打印一個名為sol的數組。 每個字符之間的距離應位於3個“字符”之間。
但是 ,當我運行代碼時,僅打印數組的第一行。
這是我的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
我的功能是:
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
所以,能請你幫我嗎?
乍一看,我不喜歡這樣的指示:
mov al, ds:[temp][si]
我想你期待它會讀取地址等於[臨時]和SI的內容的內容之和的字節。
但事實並非如此。 該指令實際上使用了address_of_temp + si。 不使用[temp]的內容。
在這里,我建議僅使用si作為指針,並考慮其他有關循環結束的比較。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.