简体   繁体   中英

Assembly Language MASM jumping

   .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 ?
rejected byte cr, Lf, "Rejected", 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

         jmp forever

message: output rejected
         jmp forever

finish:
    INVOKE ExitProcess, 0

PUBLIC _start
        END

I'm having difficulty adjusting this assignment to meet this condition: Make sure you jump forward to the bottom of the loop, and from there back to the top, so that every jump to top comes from exactly the same place.

I have accomplished the task but I seem to be jumping from multiple places. How do I adjust the program to meet the condition.

You need to change your code that you have exactly one jmp forever . With a label you can jump from several places to this jmp forever . My suggestion:

processing:
         cmp number,10
         jg message

         cmp number,-10
         jl message

         jmp skipmsg

message: output rejected
skipmsg: jmp forever

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM