outerLoop:
skipCarry:
mov eax, 2
mov inCompare, eax ;Set our inCompare to 2
mov eax, outCompare
push ecx ;Save status of these registers before entering the innerLoop
push eax
mov ecx, innerLoopCount
isComposite:
mov eax, outCompare ;Value to be checked for composite
mov edx, 0 ;Make sure edx does not have a left over value
div inCompare ;Divide outCompare by inCompare to see if we get a remainder of 0 in edx
cmp edx, 0
jne skipPrint ;If the remainder is not 0, we have not proven that the number in question is composite, so do not print
;Print out a composite value if its been proven
mov eax, outCompare
call WriteDec
mov edx, OFFSET spaces
call WriteString ;Write spaces between the composites
mov ebx, writeCounter
inc ebx ;This will help to make sure we start a new line after writing 10 composites
mov writeCounter, ebx
cmp ebx, 10 ;If counter is at 10, we start a new line
jne exitInnerLoop ;exit the inner loop because we found that the number in question is composite
call CrLf
mov writeCounter, 0
jmp exitInnerLoop ;exit the inner loop because we found that the number in question is composite
skipPrint: ;Jumped to if the number in question was not confirmed to be composite
;This is to continue testing for composite of the number in question by incrementing the divisor
mov ebx, inCompare
inc ebx
mov eax, outCompare
cmp eax, ebx
je exitInnerLoop
mov inCompare, ebx
skipIncrement: ;Will be jumped to if there are no new divisors to be tested
loop isComposite ;Retest with new divisior if there is a possibility
exitInnerLoop:
pop eax ;restore outer loop status
pop ecx
inc eax ;Next number to check for being composite
mov outCompare, eax
loop outerLoop
ジャンプがouterLoopを参照して5バイト長すぎるというエラーコードが表示されます。jmp コマンドを使用して自分でカウンターを追跡する方が簡単であることはわかっていますが、私の宿題では代わりにループを使用する必要があります。ループの範囲を拡張する方法はありますか、またはループ内のコンテンツを 5 バイト縮小する方法はありますか?
ループは、機能がわかるように、数値が合成されているかどうかをチェックすることになっています。