Use of asm("nop")

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi freaks,

 

can anyone explain ,what is the Exact use asm("nop") function.

 

 

smiley

Last Edited: Fri. Jan 8, 2016 - 10:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

It puts a "NOP" (No operation - effectively a 1 cycle delay) into the sequence of the code that is generated. At 1MHz for example a NOP takes 1us to execute so it could be used for a 1us delay. Another use sometimes is simply to put a recognisable opcode into the generated code simply to give you somewhere to put a breakpoint.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

please don't use an old thread for this.

 

[I've now split this to be separate and will PM OP - Cliff]

 

Last Edited: Fri. Jan 8, 2016 - 10:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi freaks,

 

This is my snippet,i have open any board,

 

    printf("ENTER THE BOARD TO OPEN [1 - %d] : ", usCards)

 

     scanf("%hu", &usBrdNo);

 

can anyone explain use of format-specifier %hu

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Certainly, go to a browser, choose a search engine such as Google, Bing or similar and type in "scanf %25hu".  Then click on the links suggested.

 

David 

 

<edit> typo

Last Edited: Fri. Jan 8, 2016 - 01:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The format specifiers for printf() and scanf() are virtually identical. You use 'd' for signed int, 'u' for unsigned int and you add 'h' as a prefix to say "half" - that is "short" (just as you might use 'l' to say "long" as in %ld). As it happens on an AVR both "unsigned short" and "unsigned int" are both 16 bits so it makes little difference whether you use "%hu" or just "%u" but if you took the code to a machine with 32 bit int's you would notice a difference. A %hu (or just %u) on an AVR will accept 0..65535.

 

PS I'm guessing the thread title I made for this split thread "use of asm("nop")" was not general enough and it should just have been something like "computers - everything you ever wanted to know but were too afraid to ask"? ;-)

Last Edited: Fri. Jan 8, 2016 - 01:56 PM