flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Inline Assembly & C Question - Concerning Variables

Author
Thread Post new topic Reply to topic
Steve



Joined: 10 Sep 2005
Posts: 10
Steve
Hi.

I know this isn't the best place to put this but I thought I'd put it here since this is related to OS development for me.

What I want to do, for example, is move the information from eax into a variable defined in C. How would I do this properly? Basically what I want to do is move data from a register into a C variable.

I've tried several ways which were messy since I don't grasp the GCC inline syntax very well. The times I tried and got the C file to compile, it failed when I linked them into the bin.

Thank you,

- Steve
Post 27 Apr 2006, 15:21
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Move to a decent compiler with decent inline assembly support - vc2003 toolkit is free Smile
Post 27 Apr 2006, 15:31
View user's profile Send private message Visit poster's website Reply with quote
Kermil



Joined: 26 Oct 2005
Posts: 35
Location: Russia
Kermil
I work with inline assembler not long ago, but I think the following example help you:

#include <stdio.h>

int main(void)
{
unsigned int result;

__asm__ ("movl $783, %%eax" : "=a" (result));//move eax to result variable

printf("Result: %d", result);

return 0;
}
Post 28 Apr 2006, 09:12
View user's profile Send private message ICQ Number Reply with quote
Raedwulf



Joined: 13 Jul 2005
Posts: 375
Location: United Kingdom
Raedwulf
This could help! using intel syntax in GCC:

http://www.reversing.be/article.php?story=20051203194931893

_________________
Raedwulf
Post 28 Apr 2006, 12:41
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.