your favorite function

Programming, for all ages and all languages.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: your favorite function

Post 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
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: your favorite function

Post 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
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: your favorite function

Post by NickJohnson »

User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: your favorite function

Post 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:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: your favorite function

Post 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.
User avatar
scgtrp
Member
Member
Posts: 30
Joined: Sat Mar 28, 2009 7:32 pm

Re: your favorite function

Post 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.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: your favorite function

Post 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;
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: your favorite function

Post 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.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: your favorite function

Post by qw »

JamesM, please don't spoil my joke! The & operator in this case is optional. In my opinion it even is redundant.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: your favorite function

Post 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 `()`"
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: your favorite function

Post by qw »

Let's agree to disagree. I prefer to call funcptr() instead of (*funcptr)() as well.
User avatar
edfed
Member
Member
Posts: 42
Joined: Wed Apr 09, 2008 5:44 pm
Location: Mars

Re: your favorite function

Post 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.
welcome in my dream.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: your favorite function

Post 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
User avatar
edfed
Member
Member
Posts: 42
Joined: Wed Apr 09, 2008 5:44 pm
Location: Mars

Re: your favorite function

Post 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.
welcome in my dream.
Post Reply