Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!necntc!ima!johnl From: johnl@ima.ISC.COM (John R. Levine) Newsgroups: comp.sys.ibm.pc Subject: Re: NOP Message-ID: <720@ima.ISC.COM> Date: Fri, 25-Sep-87 16:08:23 EDT Article-I.D.: ima.720 Posted: Fri Sep 25 16:08:23 1987 Date-Received: Sun, 27-Sep-87 03:04:19 EDT References: <2306@sphinx.uchicago.edu> Reply-To: johnl@ima.UUCP (John R. Levine) Organization: Not enough to make any difference Lines: 26 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? No, the 8088 is plenty slow already without any help from the assembler. You'll probably find that the NOPs always follow a two-byte jump that is jumping to an address later in the program. On the first pass, the assembler assumes that it'll need a three-byte jump, but finds on the second pass that the target is close enough that a two-byte jump, which is faster, will do. It puts in the NOP to avoid changing the addresses of all later code. It is possible to write assemblers that get the short vs. long jumps correct in almost all cases. Every Unix assembler I've seen on machines with such jumps does so, at least as far back as the PDP-11 fifth edition ca. 1974. It turns out that getting the correct jump in every case is an NP complete problem, so barring a major advance in complexity theory, it's too hard. Getting the right answer in most cases is pretty easy. There's a classic paper by Szymanski in the CACM about 10 years ago that explains it all. -- John R. Levine, IECC, PO Box 349, Cambridge MA 02238-0349, +1 617 492 3869 { ihnp4 | decvax | cbosgd | harvard | yale }!ima!johnl, Levine@YALE.something The Iran-Contra affair: None of this would have happened if Ronald Reagan were still alive.