开发者

What does '__asm__(".previous");' mean?

While trying to compile my project, that uses some third party headers, with mingw 4.4, I encountered the following error:

Assembler messages:

Error: junk at end of line, first unrecognized character is '"'

Error: unknown pseudo-op: '.previous'

I found this code at the end of one of the included headers:

__asm__(".section \".plc\"");
__asm__(".开发者_C百科previous");

Since I do not have any experience at all with in-line assembler instructions, I googled for an explanation to it, but couldn't find the answer to my two basic questions. What does __asm__(".previous"); acctually do and why would anyone put this at the end of a header file.

These are the only __asm__ instructions in the whole project. Can I safely delete them? Or is there a way to define .previous in order to make it a known pseudo-op?

Enlighten me, please!


.previous is a directive that lets you swap back and forth between two elf sections. It is a shortcut that allows denser assembly files and lets you for example declare initialized data within a stream of code or vice versa.

For example say you have an assembler file with a data and a code section.

If you want - in the middle of a function - declare a constant in the data segment you can use the .previous statement like this:

  nop            // some code

.previous        // swaps current section (code) with previous section (data)

MyConstant:
  .word 0x0001   // some data

.previous        // swaps curent section (data) with previous section (code)

  nop            // more code

More information can be found in the reference manual:

http://sourceware.org/binutils/docs-2.19/as/Previous.html#Previous

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜