我目前有这段代码:
.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个循环使这个代码更简单。我如何在汇编程序中执行嵌套循环?
答案 0 :(得分:0)
这是一种解决方案,仅使用8086/8088指令。它不依赖于386指令,因此应该在任何8086/8088 +仿真器中运行。
这个程序的想法是我们在*和笑脸(02h)之间交替打印25个字符。我们每行打印5个字符(在每个字符后面向前推进光标),如果我们打印了5个字符,则跳到下一行的开头。我们这样做直到打印出所需字符数(25)。
要在*和笑脸之间交替,我使用的事实是我想要的字符取决于我正在处理的当前字符(在 DI 中)是奇数还是偶数。如果是偶数我打印*,如果它是奇数我打印笑脸。
我在代码中提供了注释,以便了解每个步骤中发生的情况。我将这些寄存器用作变量。
export WORK_DIR=/user/hue/Bayes-Test/newTestData
mahout seqdirectory -i ${WORK_DIR}/data-all -o {WORK_DIR}/data-seq -ow
// use either -lnorm -n 2 (log L2 length normalization) or no normalization
mahout seq2sparse -i ${WORK_DIR}/data-seq -o ${WORK_DIR}/data-vectors -nv -wt tfidf
// adjust the randomSelectionPct down to 40 for a 60/40 train/test set
mahout split -i ${WORK_DIR}/data-vectors/tfidf-vectors --trainingOutput ${WORK_DIR}/train-vectors --testOutput ${WORK_DIR}/test-vectors -randomSelectionPct 40 --overwrite --sequenceFiles -xm sequential
mahout trainnb -i ${WORK_DIR}/train-vectors -o ${WORK_DIR}/model -li ${WORK_DIR}/labelindex -ow -c
mahout testnb -i ${WORK_DIR}/test-vectors -m ${WORK_DIR}/model -l ${WORK_DIR}/labelindex -c
我使用的代码是:
BP = Num of characters per row
DI = Current character number we are processing
BH = Current text page to print on
BL = Attribute to use when printing to screen
CX = Total number of characters to print with int 10h/ah=09h. Always = 1
DH = Current cursor row
DL = Current cursor column