www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - assembler parameter

reply nobody <nobody notpossible.com> writes:
Hello,

this programm should print 5;

int fak(int count) {

        asm {
                naked;
                //mov EAX,7;                // print 7
                mov EAX, [ESP+4];        // load parameter count
                ret;                              // get EAX
        }
}

void main() {
        int f = fak(5);
        writefln(f);
}
May 31 2007
parent Deewiant <deewiant.doesnotlike.spam gmail.com> writes:
nobody wrote:
 int fak(int count) {
 
         asm {
                 naked;
                 //mov EAX,7;                // print 7
                 mov EAX, [ESP+4];        // load parameter count
                 ret;                              // get EAX
         }
 }
count is already in EAX. See "Parameters" under "Function Calling Conventions" at http://www.digitalmars.com/d/abi.html
May 31 2007