Inline Assembly Help request
Hi all,
Continuing to figure out how to translate this C in assembly:
static inline int __put_user_u64(unsigned long long val, unsigned long long
* ptr)
{
int err;
err = (int) put_user((unsigned int)(val>>32) ,(unsigned int *)ptr);
err |= (int) put_user((unsigned int)val,(unsigned int *)ptr+1);
return err;
}(needed for > evms-1.1.0)
With many luck, I found interresting references about online assembly in gcc.
But I do not yet find explanation about details of the following asm code:
#define __put_user_asm(stx,x,ptr) \
__asm__ __volatile__ ( \
"\n1:\t" stx "\t%2,0(%%sr3,%1)\n" \
"2:\n" \
"\t.section __ex_table,\"a\"\n" \
"\t.word\t1b\n" \
"\t.word\t(2b-1b)+1\n" \
"\t.previous" \
: "=r"(__pu_err) \
: "r"(ptr), "r"(x), "0"(__pu_err))which is more clear with gcc -S:
1: stw %r21,0(%sr3,%r19)
2:
.section __ex_table,"a"
.word 1b
.word (2b-1b)+1
.previousMy questions are:
what are the actual means "1:", "2:" (seems like label?)
and what means the rest
".section __ex_table,...
...
.previous"
I do not yet found reference on this part (even in Assembly-HOWTO). Where could I found doc on this details?
Thanks in advance for attention,
Joel
Big Brother Anders - With Tiscali you will see it all ! Check it up on
www.tiscali.be/bigbrother
Quoted 16 lines
But I do not yet find explanation about details of the following asm code:
#define __put_user_asm(stx,x,ptr) \ __asm__ __volatile__ ( \ "\n1:\t" stx "\t%2,0(%%sr3,%1)\n" \ "2:\n" \ "\t.section __ex_table,\"a\"\n" \ "\t.word\t1b\n" \ "\t.word\t(2b-1b)+1\n" \ "\t.previous" \ : "=r"(__pu_err) \ : "r"(ptr), "r"(x), "0"(__pu_err))which is more clear with gcc -S:
1: stw %r21,0(%sr3,%r19)
2:
Quoted 7 lines
.section __ex_table,"a" .word 1b .word (2b-1b)+1 .previousMy questions are:
what are the actual means "1:", "2:" (seems like label?)
They are local labels that can be referenced in the asm. "b" and "f" mean backwards and forward relative to the current location. This more or less doubles the number of labels available.
Quoted 7 lines
and what means the rest
".section__ex_table,...
...
.previous"I do not yet found reference on this part (even in Assembly-HOWTO). Where could I found doc on this details?
The GCC manual (extend.texi) has documentation on writing asms. You will need to look at the pa-risc architecture manuals for documentation on PA assembler instructions.
The code is trying to setup a table using local labels generated in the asm. The way to do this is highly port dependent. In particular, indirect function calls are done using plabels on the PA. There are also restrictions on the types of relocations that can be used for constructing tables of this kind.
This is highly complex stuff and isn't very well documented. You can read the HP runtime architecture document, the documentation on ELF relocations and look at the code in the GNU assembler and linker. The dwarf2 exception tables that you can generate with gcc 3.3 may also give some clue. Look at the entry for the personality function and how the labels for C++ catches are encoded in the table.
Dave
Signature · 2 lines
J. David Anglin [email protected] National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
[parisc-linux] followup: Inline Assembly Help request
Hi all,
Following my investigation to fix the problem of 64bits integer transfer between kernel and user space (put_user in uaccess.h), I still had a problem:
how to access of the two int (32bit) parts of a long long?
In mips sources I found this interresting stuff:__put_user_asm_ll32
...
1: sw %1, %2
2: sw %D1, %3....
which would correspond to what I need but it is not available for hppa.
So I do something like:
...
#define STD_USER(x, ptr) \
({ \
unsigned int xh = (unsigned int)(x>>32), \
xl = (unsigned int) (x); \
__put_user_asm_64(xh, xl, ptr); \})
...
and so
...
#define __put_user_asm_64(xh, xl, ptr) \
__asm__ __volatile__ ( \
"\n1:\tstw\t%2,0(%%sr3,%1)\n" \
"2:\tstw\t%3,4(%%sr3,%1)\n" \
"3:\n" \
"\t.section __ex_table,\"a\"\n" \
"\t.word\t1b\n" \
"\t.word\t(3b-1b)+1\n" \
"\t.word\t2b\n" \
"\t.word\t(3b-2b)+1\n" \
"\t.previous" \
: "=r"(__pu_err) \
: "r"(ptr), "r"(xh), "r"(xl), "0"(__pu_err))...
which has a border effect:tty_ioctl.c: In function `get_termio':
tty_ioctl.c:175: warning: right shift count >= width of type tty_ioctl.c:175: warning: right shift count >= width of type tty_ioctl.c:175: warning: right shift count >= width of type tty_ioctl.c:175: warning: right shift count >= width of type tty_ioctl.c:175: warning: right shift count >= width of type
Is there some other means somewhere else?
Thanks in advance,
Joel