1
#define INLINE_SYSCALL(name, nr, args...) \
  ({                                          \
    unsigned int resultvar;                           \
    asm volatile (                                \
    LOADARGS_##nr                                 \
    "movl %1, %%eax\n\t"                              \
    "int $0x80\n\t"                               \
     RESTOREARGS_##nr                                 \
    : "=a" (resultvar)                                \
    : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc");              \
   if (resultvar >= 0xfffff001)                       \
     {                                        \
        __set_errno (-resultvar);                         \
        resultvar = 0xffffffff;                           \
      }                                       \
    (int) resultvar; })

#define LOADARGS_0
#define LOADARGS_1 \
"bpushl .L__X'%k2, %k2\n\t"                           \
"bmovl .L__X'%k2, %k2\n\t"
#define LOADARGS_2  LOADARGS_1
#define LOADARGS_3  LOADARGS_1
#define LOADARGS_4  LOADARGS_1
#define LOADARGS_5  LOADARGS_1

who knows the meaning of the following asm code

#define LOADARGS_1 \
"bpushl .L__X'%k2, %k2\n\t"                           \
"bmovl .L__X'%k2, %k2\n\t"

can someone explain this to me %2 means the third parameters in asm input and output so %k2 means what and what's meaning of .L__X bpushl and bmovl seems no such instruction for ia32

Kara
  • 5,650
  • 15
  • 48
  • 55
Adambynes
  • 167
  • 1
  • 10

1 Answers1

0

The %2 and %k2 are register constraints, which are described well here: Simple Constraints

bpushl and bmovl are macros defined by uClibc in syscalls.h, and seems to be meant to preserve the previous value in %ebx before clobbering it.

.L__X is defined in the same file.

superdesk
  • 1,067
  • 10
  • 23
  • for .L__X'%ebx = 1\n\t i cannot understand the meaning, giving value to the symbol .L__X or .L__X'%ebx or has some other meanings@superdesk – Adambynes Feb 13 '14 at 10:55
  • .if 1 - \\name\n\t what is the meaning of \\ i think \ is for the resolve the value of name but \\ is using escape for \, so what's the use in here@superdesk – Adambynes Feb 13 '14 at 10:59
  • You are probably right about the \\. It resolves to \, so that the macro has `\name` in it. When the macro is used, `.L__X'%k2` replaces \name (I think). This gives you `.if 1 - .L__X'%k2` inside the bpushl macro. L__X itself is a macro... it looks like it is either 1, 2 or 3 depending on the register. So `.if 1 - 1` might be the final line... But I'm not sure about any of this. – superdesk Feb 13 '14 at 16:26
  • You may want to try to compile the code to see what it actually looks like. You can tell gcc to output the assembly (instead of an object file), or you may be able to run the code through the pre-processor to see what happens with the defines / macros. I'm not an expert here, so I likely won't be able to help with any problems you have here. – superdesk Feb 13 '14 at 16:29
  • thanks for the reply finally i find the \\ is used for inline asm syntax and \ is used for the .marco in asm for GNU assembler, and inline asm will simply expand to the asm, the inline asm even don't need to know the syntax about asm, so we should make a clear head about the inline asm and asm syntax! – Adambynes Feb 19 '14 at 08:57