Andes Workshop

It is currently Tue Jun 27, 2017 12:40 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: nop的使用
PostPosted: Fri Feb 17, 2012 12:43 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
NOP指令對於我們要找bug時有用處。
例如我們想要快速的找出某行C code所在的位址。
或是將指令往後移,填空白等等。

指令為NOP或NOP16,後者為16 bit指令。
下面是例子。

#include <stdio.h>
#include <stdlib.h>

volatile char variTest = 0;
void func();

int main(void) {
func();
return EXIT_SUCCESS;
}

void func ()
{
__asm__ volatile ("nop");
__asm__ volatile ("nop16");

while (!(variTest & 0x08));
__asm__ volatile ("nop");
__asm__ volatile ("nop");

}

產生的指令如下,我發現它都是16bit指令。
Attachment:
nop.gif
nop.gif [ 9.19 KiB | Viewed 4232 times ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group