Any other way? INT abstraction

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Last I checked, you can't run interrupts in C without ASM.

To pass and return variables (the way I do my syscalls).....

Code: Select all

asm("int $0x80":"=S"(retval):"a"(value), "b"(value), "c"(value));
Sorry if this was answered already, I'm short on time.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

zaleschiemilgabriel wrote:Well, C was originally written in assembly language, and now, for OS development people are trying to "emulate" assembly-like instructions in C. That's funny.
No, you think that's funny. But it really isn't.


JAL
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Any other way? INT abstraction

Post by jal »

neon wrote:Any suggestions are appreciated
To sum up everything said here, you've got two options:
1) use self modifying code
2) use a jump table (or case switch)


JAL
eddyb

Post by eddyb »

maybe u can make a file only for this, with to content:

Code: Select all

int _int_no;

void gen_int(int int_no)
{
_int_no = int_no;

asm("int _int_no");
}
also u can(if u want top can put, get the value of regs)

Code: Select all

int _int_no;
int _eax;
int _ebx;
int _ecx;
int _edx;

void gen_int(int int_no, int * eax, int * ebx, int * ecx, int * edx)
{
_int_no = int_no;
_eax = eax;
_ebx = ebx;
_ecx = ecx;
_edx = edx;

asm(
"movl _eax, eax"
"movl _ebx, ebx"
"movl _ecx, ecx"
"movl _edx, edx"
"int _int_no"
"movl eax, _eax"
"movl ebx, _ebx"
"movl ecx, _ecx"
"movl edx, _edx"
);

eax = _eax;
ebx = _ebx;
ecx = _ecx;
edx = _edx;
}
User avatar
devel
Member
Member
Posts: 62
Joined: Wed Nov 28, 2007 4:15 am
Contact:

Post by devel »

hi,
I think this will not work since 'int' instruction requires immediate operand.

regards,
devel.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Post by neon »

Everyone knows this thread was posted Sept 7, 2007 right...?

Problems already solved some time ago ;)

Thanks for the extra suggestions though :)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

devel wrote:hi,
I think this will not work since 'int' instruction requires immediate operand.

regards,
devel.
@eddyb:
I want to add here that the amount of uneducated (read: plain wrong) remarks you have posted are pretty large. Please watch out what you're claiming as providing the wrong information is in most cases worse than providing no information. In fact the reason why your code won't work has been posted earlier as well.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply