Page 3 of 3

Re: your favorite function

Posted: Wed Nov 18, 2009 7:54 pm
by earlz
Combuster wrote:must...not...feed...troll

I rest my case.
It must be hard being an ex-mod where you can just see in your head the ban button.. lol

Re: your favorite function

Posted: Thu Nov 19, 2009 9:32 pm
by VolTeK
OT: im sorry, but when did the great combuster become an "ex-mod"??
respond to this if u want, otherwise please keep thread going, this is very interesting

Re: your favorite function

Posted: Fri Nov 20, 2009 5:09 am
by NickJohnson

Re: your favorite function

Posted: Fri Nov 20, 2009 8:47 am
by Brynet-Inc
GhostXoPCorp wrote:OT: im sorry, but when did the great combuster become an "ex-mod"??
respond to this if u want, otherwise please keep thread going, this is very interesting
The day they realized he could think for himself, the powers that be don't like that quality very much. :wink:

Re: your favorite function

Posted: Fri Nov 20, 2009 10:25 am
by JamesM
geppyfx wrote:Or do you suggest I learn ObjC? Maybe objc_msgSend is a macro or compiler/language related function? How come programming language related issues belong to osdev site not to mention "OS Development" forum(before it was moved).
The reason Combuster mentioned this is that Objective-C is based on a message-passing architecture. I don't know ObjC myself, but I know this much. Thus, I must conclude that objc_msgSend is the integral dispatcher function that allows all object-oriented calls in ObjC; a truly important function.

So this thread is indeed not pointless as you and possibly others who search here have just learned something. Which is, again, Combuster's point.

Re: your favorite function

Posted: Fri Nov 20, 2009 3:00 pm
by scgtrp
Seriosly, which function can you remove and keep functionality of the kernel at the same level?

Code: Select all

void do_nothing() {}
My favorite function: besides the obvious print() and supporting stuff, I'd have to say _start and ap_start are rather interesting.

Re: your favorite function

Posted: Sat Nov 21, 2009 5:55 am
by qw
scgtrp wrote:
Seriosly, which function can you remove and keep functionality of the kernel at the same level?

Code: Select all

void do_nothing() {}
Hey, you can't remove that function! Removing it would break

Code: Select all

static void (*const pointless_pointer)() = do_nothing;

Re: your favorite function

Posted: Sat Nov 21, 2009 9:56 am
by JamesM
Hobbes wrote:
scgtrp wrote:
Seriosly, which function can you remove and keep functionality of the kernel at the same level?

Code: Select all

void do_nothing() {}
Hey, you can't remove that function! Removing it would break

Code: Select all

static void (*const pointless_pointer)() = &do_nothing;
FTFY.

Re: your favorite function

Posted: Sat Nov 21, 2009 12:04 pm
by qw
JamesM, please don't spoil my joke! The & operator in this case is optional. In my opinion it even is redundant.

Re: your favorite function

Posted: Sat Nov 21, 2009 7:07 pm
by earlz
Hobbes wrote:JamesM, please don't spoil my joke! The & operator in this case is optional. In my opinion it even is redundant.
It can be less ambiguous for the person doing the programming though. Seeing it without the & makes the next person to work on it think "hmm.. Well thats where that bug is, they meant to put `()`"

Re: your favorite function

Posted: Sun Nov 22, 2009 1:37 pm
by qw
Let's agree to disagree. I prefer to call funcptr() instead of (*funcptr)() as well.

Re: your favorite function

Posted: Thu Nov 26, 2009 9:00 am
by edfed
Asm (func,op1,op2,op3,op4,op5,op6,op7,op8)

basically, this function calls func, and func will use op1 up to op8 as parameters.
func is pure asm code, terminated by a ret.

Re: your favorite function

Posted: Thu Nov 26, 2009 9:24 am
by AJ
edfed wrote:Asm (func,op1,op2,op3,op4,op5,op6,op7,op8)

basically, this function calls func, and func will use op1 up to op8 as parameters.
func is pure asm code, terminated by a ret.
I don't like the look of that - if you really had to create your own assembly linkage, how about:

Code: Select all

Asm(func,argc,...)
?

I use something similar to this version for calling real mode functions from protected mode. For Pmode->Pmode calls, I used the System V ABI, declare the function as extern "C" and just call it directly.

Cheers,
Adam

Re: your favorite function

Posted: Thu Nov 26, 2009 9:38 am
by edfed
you don't know how it works, why do you say you don't like that?

lets say, it's not code, but only datas, pointed to by esi.

in pure asm, it have this form:

Code: Select all

mov esi,asmtest
call caller
...
asmtest dd f.asm,@f,1,2,3,4
@@:
push eax ebx ecx edx
mov eax,[esi+asm.op1]
mov ebx,[esi+asm.op2]
lea eax,[eax*8+ebx+45]
mov ecx,[esi+asm.op3]
mov [ecx],eax
mov edx,[esi+asm.op4]
lea eax,[ecx*4+ebx]
mov [edx],eax
pop edx ecx ebx eax
ret
the asm fucntion permits to use asm code inside fool tree.

as an example, it is a basic implementation of asm for fool design.

Code: Select all

Asm movdw,destination,source
will do that:

Code: Select all

mov eax,[esi+asm.op1]
mov ebx,[esi+asm.op2]
mov [eax],ebx
then, if i want this object to do something else, it is easy, just replace movdw by the label you want.