0
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
Include io.h
cr equ 0DH
Lf equ 0AH
.STACK 4096
.DATA
string byte 40 Dup (?)
number dword ?
runningSum dword 0
rejected byte " , Rejected", 0
positive byte cr, Lf, "Positive",0
negative byte cr, Lf, "Negative",0
numaschar byte 11 dup(?),0
newline byte cr,Lf,0
.code
_start:
forever: input string, 40
atod string
mov number, eax
cmp number,0
jne processing
je finish
processing:
cmp number,10
jg message
cmp number,-10
jl message
cmp number,10
jle not_rejected1
cmp number,-10
jge not_rejected2
jmp jumpToTop
message: dtoa numaschar,number
output numaschar
output rejected
output newline
not_Rejected1: cmp number, -10
jge processing2
not_Rejected2: cmp number,10
jle processing2
processing2: cmp number, 0
jg addInstruct
jl subInstruct
addInstruct: add ebx, 1
add edx,number
jmp message2
subInstruct: add ecx, 1
jmp message3
message2: dtoa numaschar, number
output positive
output newline
message3: dtoa numaschar, number
output negative
output newline
jumpToTop: jmp forever
finish:
INVOKE ExitProcess, 0
PUBLIC _start
END
,当该程序在一个正数,它是如何来打印这两条消息“积极”和“消极”记载,但我需要它来只打印消息“正”MASM大会跳转指令打印问题
任何帮助表示赞赏。谢谢 !
.............................................. .................................................. .....
我可以在哪里将跳转到顶部的声明,以便我只需将它放在一个位置而不是从多个位置跳转?可能吗 ? – 2014-12-05 20:45:56
使用call指令,可以避免多次使用jmp。然后只能用ret指令完成后退跳转。 – 2014-12-05 20:49:01
@AmberBexley - 在仔细研究你的代码时,我可能会在标签'message3'之前添加'jmp jumpToTop'作为代码行。当然,你跳转到一个跳转的位置 - 如果你的代码只是简单地跳到“永远”,那么你的代码会更有效率,但如果你只跳转到jumpToTop,那么它更容易阅读(imho)。无论你是向前还是向后跳,你(或多或少 - 见van Uitkon的评论)**需要**在执行代码之后有一个_follows_ _message2'_标签**和**在' message3' label_。 – enhzflep 2014-12-05 20:51:50