Page 2 of 2 FirstFirst 12
Results 16 to 16 of 16
  1. #16
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by B1ackAnge1 View Post
    For this sample it indeed doesn't matter because you have basicallyu
    0, string, string , 0

    But when coding in asm I always tend to use Stdcall
    so Function(A,B,C) would be
    push C
    Push B
    push A
    Call Function.

    The function itself would know in which order to pop from the stack, hence why a lot of times when dealing with DLLs etc in C++ you'd see 'Extern C' which is basically saying: the functions in the dll are expecting their data to be passes using stdcall

    stdcall != cdecl but that's too much typing righ tnow
    from what I appear to think I remember(holy crap, even that sounds confusing o__O)
    cdecl would be like:
    Function(A,B,C)
    push A
    Push B
    push C
    Call Function.

    I guess ill have to search the almighty wikipedia, as im starting to doubt ;(

    Edit:
    The almighty wikipedia makes me look dumb... I'll have to edit that article to make me look smart
    Quote Originally Posted by wikipedia
    The cdecl calling convention is used by many C systems for the x86 architecture. In cdecl, function parameters are pushed on the stack in a right-to-left order. Function return values are returned in the EAX register (except for floating point values, which are returned in the x87 register ST0). Registers EAX, ECX, and EDX are available for use in the function.

    For instance, the following C code function prototype and function call:

    Code:
    int function_name(int, int, int);
    int a, b, c, x;
    ...
    x = function_name(a, b, c);
    will produce the following x86 Assembly code (written in MASM syntax, with destination first):

    Code:
    push c
    push b
    push a
    call function_name
    add esp, 12 ;Stack clearing
    mov x, eax
    Quote Originally Posted by wikipedia
    syscall

    This is similar to cdecl in that arguments are pushed right to left. EAX, ECX, and EDX are not preserved. The size of the parameter list in doublewords is passed in AL.

    Syscall is the standard calling convention for 32 bit OS/2 API.
    Quote Originally Posted by wikipedia
    optlink

    Arguments are pushed right to left. The three lexically first (leftmost) arguments are passed in EAX, EDX, and ECX and up to four floating-point arguments are passed in ST(0) through ST(3), although space for them is reserved in the argument list on the stack. Results are returned in EAX or ST(0). Registers EBP, EBX, ESI, and EDI are preserved.

    Optlink is used by the IBM VisualAge compilers.
    Quote Originally Posted by wikipedia
    stdcall

    The stdcall[1] calling convention is a variation on the pascal calling convention in which parameters are passed on the stack, pushed right-to-left. Registers EAX, ECX, and EDX are designated for use within the function. Return values are stored in the EAX register. The callee is responsible for cleanup of the stack.

    Stdcall is the standard calling convention for the Microsoft Win32 API and for Open Watcom C++.
    Last edited by Hell_Demon; 01-21-2010 at 09:26 AM.
    Ah we-a blaze the fyah, make it bun dem!

Page 2 of 2 FirstFirst 12

Similar Threads

  1. [C++] Tutorial 2: Hello World
    By Schyler in forum C++/C Programming
    Replies: 12
    Last Post: 03-28-2010, 10:53 PM
  2. New o C++? Simple Hello world (Added a little extra)
    By headsup in forum C++/C Programming
    Replies: 10
    Last Post: 11-09-2009, 06:00 PM
  3. Hello World Anyone?
    By B1ackAnge1 in forum Assembly
    Replies: 11
    Last Post: 11-09-2009, 01:14 PM
  4. A closer look at Hello World App.
    By headsup in forum Java
    Replies: 5
    Last Post: 10-24-2009, 12:25 AM
  5. [C++]Hello World; Your first C++ Program
    By Mr. Bond in forum Programming Tutorials
    Replies: 3
    Last Post: 02-09-2009, 08:53 AM