Questions tagged [no-op]

No-op (also spelled as "noop" and "nop") is an abbreviation for "no-operation". It is code that does nothing and has no effect. It is used for filling space (adding padding) and/or wasting time. "nop" is a common instruction in assembly language.

The great art of doing nothing

What is it, and how did it come to be?

No-OPeration (nop, no-op) is the proper instruction to instruct a processor to do nothing (but waste time).
Just about every has at least some s which have no effect at all. They naturally occur because it pays to build a regular IS, which leads to curiosities like exchange A for A, assign A to A, bitwise-and/or A and A.

While some of those may be redefined for better instruction density, one will be chosen as intended nop.

Purpose/Uses

There are a great many uses for doing nothing. Some examples:

  • Reserving space for adding patches

    Some Windows system binariesreserve space to allow live-patching.

  • Neutralizing code

    An example is an implementation of a seldom changed flag in high-performance-code: Either there's an unconditional jump to additional code, or there's a single, efficient nop

  • Aligning code for better caching

    If a function begins at the start of a cache-line (or even memory-page), there will often be fewer cache-misses

  • Wasting time

    Counting instructions and busy-Loops for delaying are getting less common in high-end systems, though they are still alive and well on slower machines.

  • (Attacking) Making a bigger target for a (semi-)blind jump by building a nop-slide.

References

115 questions
2
votes
1 answer

TypeScript: noop => noop

I've seen the syntax noop => noop here. I was rather expecting something like () => noop to be valid. What does noop => noop stand for and when should one use this?
Michael H.
  • 3,323
  • 2
  • 23
  • 31
2
votes
1 answer

Checking FTP connection is valid using NOOP command

I'm having trouble with one of my scripts seemingly disconnecting from my FTP during long batches of jobs. To counter this, I've attempted to make a module as shown below: def connect_ftp(ftp): print "ftp1" starttime = time.time() retry…
wonk
  • 92
  • 1
  • 10
2
votes
1 answer

Why does ILGenerator.Emit() insert nop opcodes in dynamic assembly?

I am building a small compiler in C#, so inevitably I had to meddle with dynamic assemblies and emitting opcodes. Now, the odd thing is that my Emit() calls create additional nop opcodes in the generated module. It is not so much essential in my…
2
votes
1 answer

Numbers of no-ops betweeen MIPS instructions

I have a sequence of instructions as follows: I1 lw $1, 40($6) I2 add $6, $2, $2 I3 sw $6, 50($1) The question is: In a basic five-stage pipeline without forwarding, how many noops should be there between I2 and I3? I think the number is 2, while…
jiaxl
  • 81
  • 1
  • 6
2
votes
0 answers

IDA Not Recognizing Instructions as Code?

I made a new segment in the ELF (ARM) game library I am working on (Page Aligned, .text segment (Pure Code)). The entirety of the segment includes only NOPs (0000A0E1). However, IDA recognizes the NOPs as: DCD 0xE1A00000 If I press C to make it…
Aspire
  • 21
  • 1
  • 5
2
votes
1 answer

Superfluous NOPs and branches in unoptimized MSIL

When I compile the following code as debug... public class MyClass { private int myField; public int MyProperty { get { return myField; } set { myField = value; } } } ...strange bytecode with seemingly useless…
Good Night Nerd Pride
  • 8,245
  • 4
  • 49
  • 65
2
votes
4 answers

How to obtain reliable Cortex M4 short delays

I am porting some code from an M3 to an M4 which uses 3 NOPs to provide a very short delay between serial output clock changes. The M3 instruction set defines the time for a NOP as 1 cycle. I notice that NOPs in the M4 do not necessarily delay any…
Ant
  • 1,668
  • 2
  • 18
  • 35
2
votes
2 answers

Get slf4j NOP implementation to log to console

I want slf4j NOP implementation to log to the console. Currently, it just doesnt log anything, instead is there a way to have it log to the console? My use case is I have a library (not an app) which just depends on slf4j-api. But some of the…
Neha
  • 71
  • 2
  • 11
2
votes
1 answer

Empty function to preserve jquery chains

Is there a (maybe undocumented) placeholder like $.noop for the use in jQuery concatenations? To use in something like the following: $('selector')[true ? 'method' : '']().doSomething(); I've tried a lot and ended up…
yckart
  • 32,460
  • 9
  • 122
  • 129
2
votes
2 answers

Passing parameters to a no-op macro in C++

I am getting the following error message error: '0' cannot be used as a function when trying to compile the following line: NOOP(0 != width); NOOP is defined as follows: #define NOOP (void)0 The source code is part of a SDK - so it should be…
Aoshi
  • 53
  • 4
1
vote
3 answers

Python is printing 0x90c2 instead of just 0x90 NOP

The following command is outputting 200 bytes of 'A' followed by one byte of 0x0a: python3 -c "print('\x41'*200)" > out.txt hexdump out.txt confirms this: 0000000 4141 4141 4141 4141 4141 4141 4141 4141 * 00000c0 4141 4141 4141 4141…
ramon
  • 830
  • 1
  • 12
  • 12
1
vote
1 answer

GCC for Aarch64: what generated NOPs are used for?

I built CoreMark for Aarch64 using aarch64-none-elf-gcc with the following options: -mcpu=cortex-a57 -Wall -Wextra -g -O2 In disassembled code I see many NOPs. A few examples: 0000000040001540 : 40001540: 13003c63 sxth …
pmor
  • 5,392
  • 4
  • 17
  • 36
1
vote
1 answer

Placing NOPs in order to ensure no RAW Data hazard in MIPS assembly

Currently working on understanding MIPS architecture and assembly language, I've been asked to place NOPs in the following assembly code: 1 ADD R2,R1,R3 2 SW R3,0(R2) 3 ADD R4,R3,R2 4 LOOP: LW R8,2000(R4) 5 SUB R5,R4,R8 6 ORI R23,R8,370 7 ADD…
Aishgadol
  • 147
  • 6
1
vote
2 answers

Why does NHIbernate (Fluent) still execute queries for my Noop properties?

I have a user object that has a many to many relationship with project. In my user mapping, I have this: HasManyToMany(x => x.Projects).Table("UsersProjects").ParentKeyColumn("UserID").Access.None(); When I run a simple get by id…
Robert
  • 1,487
  • 1
  • 14
  • 26
1
vote
0 answers

What does it mean "nopw" in the assembly code?

I have a very simple code as below. But there is one line that I cannot interpret. pushq %rbp movq %rsp, %rbp leaq (%rcx,%rdx), %rax popq %rbp retq nopw (%rax,%rax) Above assembly code is somewhat adding two integers like 1+1. I can…