On 01/24/2010 10:51 PM, me wrote:
I'm trying to convert some 32 bit linked asm (which runs fine) into 64 bit inline asm (g++) but am stumbling at the first hurdle ie I'm getting -14 returned as the file descriptor for /dev/vcsa1. Here's my attempt. [code] //My amd64 inline asm version #include<iostream> using namespace std; void my_fn(){ const char * fl = "/dev/vcsa1"; const char * test_str = " "; //make same size as fl int test_int = -1; //ie initialised to fail unless replaced by value //1 open /dev/vcsa1& return file descriptor in rax __asm__ __volatile__( ".equ sys_open, 2\n" ".equ O_RDWR, 02\n" "mov $sys_open, %%rax\n" "mov $O_RDWR, %%rcx\n" "mov $0600, %%rdx\n" //read/write for user in x86. Not sure for AMD64? "syscall\n" :"=b"(test_str), "=a"(test_int) :"b"(fl)
This statement does not tell gcc the connections between registers and C variables. So there is no guarantee that those variables will be put into the registers you expect by the above statement.
Jie