Page 2 of 2

Posted: Tue Mar 11, 2008 8:41 am
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

Posted: Tue Mar 11, 2008 9:30 am
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

Re: Any other way? INT abstraction

Posted: Tue Mar 11, 2008 9:31 am
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

Posted: Tue Mar 11, 2008 10:52 am
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;
}

Posted: Tue Mar 11, 2008 11:43 am
by devel
hi,
I think this will not work since 'int' instruction requires immediate operand.

regards,
devel.

Posted: Tue Mar 11, 2008 1:32 pm
by neon
Everyone knows this thread was posted Sept 7, 2007 right...?

Problems already solved some time ago ;)

Thanks for the extra suggestions though :)

Posted: Tue Mar 11, 2008 2:04 pm
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.