Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!uw-june!uw-entropy!dataio!bright From: bright@dataio.Data-IO.COM (Walter Bright) Newsgroups: comp.sys.ibm.pc Subject: Re: NOP Message-ID: <1377@dataio.Data-IO.COM> Date: Mon, 28-Sep-87 14:14:09 EDT Article-I.D.: dataio.1377 Posted: Mon Sep 28 14:14:09 1987 Date-Received: Tue, 29-Sep-87 06:35:19 EDT References: <2306@sphinx.uchicago.edu> Reply-To: bright@dataio.UUCP (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 16 Keywords: NOP 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? The only place I have seen it done is following a JMP instruction where the target address is a forward reference. The reason is that MASM is 2 passes, on the first pass the values of all symbols must be determined. JMP can be 2 or 3 bytes, depending on how far away the target is. Since the target is forward referenced, MASM assumes worst case and allocates enough space for a 3 byte JMP. On pass 2, if the target is close enough that it can be a 2 byte JMP, MASM creates a 2 byte JMP followed by a NOP to fill in the 'hole'. If you want only a 2 byte JMP, use the JMP SHORT mnemonic.