0
我現在有這樣的代碼:簡化組裝程序
.model small
.stack 100h
.data
.code
CLRSCR:
mov ax,0003h
int 10h
ROWCOLINIT:
mov dh,0
mov dl,0
MYLOOP:
mov ax,dx
mov ah,0
mov bl,2
div bl
cmp ah,0
je EVENCOL
ODDCOL:
mov al,2
CURSORINIT:
mov ah,02h
mov bh,0
int 10h
ATTRIBINIT:
mov ah,09h
mov bl,30h
PRINTCHAR:
mov cx,1
int 10h
inc dl
cmp dl,5
je RESETCOLINCROW2
DONTRESETCOL:
cmp dh,5
je EXIT
jmp MYLOOP
LOOP2:
mov ax,dx
mov ah,0
mov bl,2
div bl
cmp ah,0
je EVENCOL2
ODDCOL2:
mov al,42
CURSORINIT2:
mov ah,02h
mov bh,0
int 10h
ATTRIBINIT2:
mov ah,09h
mov bl,30h
PRINTCHAR2:
mov cx,1
int 10h
inc dl
cmp dl,5
je RESETCOLINCROW
DONTRESETCOL2:
cmp dh,5
je EXIT
jmp LOOP2
EXIT:
mov ah,4ch
int 21h
RESETCOLINCROW:
mov dl,0
inc dh
jmp DONTRESETCOL
RESETCOLINCROW2:
mov dl,0
inc dh
jmp DONTRESETCOL2
EVENCOL:
mov al,42
jmp CURSORINIT
EVENCOL2:
mov al,2
jmp CURSORINIT2
end
我的程序輸出是:
*☻*☻*
☻*☻*☻
*☻*☻*
☻*☻*☻
*☻*☻*
我試圖讓使用2個迴路這個代碼更簡單。我如何去做彙編器中的嵌套循環?
確實的規格讓你改變成另一種語言? :) – lordkain
也許你應該評論你的代碼並告訴我們這個程序應該做什麼? – zx485
雖然你說要簡化爲兩個循環,但也可以用一個循環生成所需的效果(單循環也更簡單) –