Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!think!ames!amdahl!bnrmtv!perkins From: perkins@bnrmtv.UUCP (Henry Perkins) Newsgroups: comp.sys.ibm.pc Subject: Re: NOP Message-ID: <2640@bnrmtv.UUCP> Date: Fri, 25-Sep-87 15:21:01 EDT Article-I.D.: bnrmtv.2640 Posted: Fri Sep 25 15:21:01 1987 Date-Received: Sun, 27-Sep-87 08:04:04 EDT References: <2306@sphinx.uchicago.edu> Organization: BNR Inc., Mountain View, California Lines: 24 Summary: Two reasons why MASM puts NOPs in code: directives and short jumps In article <2306@sphinx.uchicago.edu>, cjdb@sphinx.uchicago.edu (Charles Blair) writes: > In debugging code written in assembly-language, I notice that MASM > periodically inserts NOP's in places where they don't appear in the > source. I imagine this is done to slow down the processor, but how > does MASM "decide" the appropriate circumstances? It's not done to "slow down the processor"; it's done to make the code size/location unambiguous. There are two reasons why MASM will insert a NOP that isn't in the original code: assembler directives and short jumps. Directives like EVEN and ORG specify where the next instruction starts; the intervening space is padded with NOPs. A single NOP is used after a short jump when the assembler source did not specify (with the SHORT pseudo-op) that the JMP was the shorter, 8-bit displacement type. Rather than use the slower 16-bit displacement jump, MASM will use a short jump and add a NOP to preserve the offset of the next instruction. If you specify that the jump is to be short, of course, no NOP is inserted. -- {hplabs,amdahl,ames}!bnrmtv!perkins --Henry Perkins It is better never to have been born. But who among us has such luck? One in a million, perhap po