.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall,dwExitCode:DWORD
Include io.h
cr equ 0DH
Lf equ 0AH
.STACK 4096
.DATA
number dword ?
string byte 40 dup(?)
rejected byte ", Rejected",cr,0
positiveNumber byte ", Positive",cr,0
negativeNumber byte ", Negative",cr,0
numberOfPos byte "Positive Numbers: ",0
numberOfNeg byte "Negative Numbers: ",0
runningSum byte "Running Sum of Positive numbers: ",0
newline byte cr,Lf,0
numaschar byte 11 dup(?),0
numPosaschar byte 11 dup(?),0
numNegaschar byte 11 dup(?),0
sumasChar byte 11 dup(?),0
.code
_start:
sub ebx,ebx ; numberOfPos = 0
sub ecx,ecx ; numberOfNeg = 0
sub edx,edx ; runningSum = 0
forever:
input string, 40
atod string
cmp eax,0
je finish
cmp eax,10
jg invalid
cmp eax,-10
jl invalid
cmp eax,0
jg positive
jl negative
jmp jumpToMainLoop
positive:
inc ebx
add edx,eax
dtoa numaschar,eax
output numaschar
output positiveNumber
output newline
negative:
add ecx,1
dtoa numaschar,eax
output numaschar
output negativeNumber
output newline
invalid:
dtoa numaschar,eax
output numaschar
output rejected
output newline
finish:
dtoa numPosaschar, ebx
dtoa numNegaschar, ecx
dtoa sumasChar, edx
output numberOfPos
output numPosaschar
output newline
output numberOfNeg
output numNegaschar
output newline
output runningSum
output sumasChar
output newline
INVOKE ExitProcess, 0
PUBLIC _start
END
jumpToMainLoop:
jmp forever
[我要做的是创建一个前向引用,在该引用中,我仅在循环结束时跳回到主循环(永远)。现在,如果我在每个无效,肯定,否定标签的末尾写上“ jmp jumpToMainLoop”,我只会知道如何跳回到主循环。我该如何调整程序,使其仅在循环结束时才跳到永远?
jmp jumpToMainLoop
这等效于jmp forever
。
[[现在,我只知道如果我在每个标签的末尾都写“ jmp jumpToMainLoop”无效,肯定,否定的情况下,如何跳回到主循环。
为什么不在这3个地方写jmp forever
(在output newline
之后!!