flat assembler
Message board for the users of flat assembler.

Index > Windows > im little lost on COFF

Author
Thread Post new topic Reply to topic
ackit



Joined: 08 Sep 2008
Posts: 3
ackit
Code:

format MS COFF
public  _power as 'power'

include 'C:\FASM\INCLUDE\WIN32A.INC'


section '.text' code readable executable

proc _power
     push ebp
    mov ebp,esp

     mov eax,[ebp+4]
     mov ebx,[ebp+8]
     mul eax

 pop ebp
     ret
endp


    

Code:
using namespace std;
extern int power(int,int);


int main(){
        int a=10,b=10;
      std::cout<<power(a,b)<<endl;
    getchar();
}

    

im little confused, g++ main.cpp power.obj
Post 07 Apr 2009, 03:25
View user's profile Send private message MSN Messenger Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 140
SFeLi
Code:
public  power as '_power'  ; Mangle exported name, not an internal one.
and in main.cpp:
#include <iostream>
and
extern "C" int power(int,int);
    
Post 07 Apr 2009, 03:50
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17671
Location: In your JS exploiting you and your system
revolution
Also:
Code:
...
        mov eax,[ebp+8]  ;first parameter
        mov ebx,[ebp+12] ;second parameter
...    
And presumably?:
Code:
...
        mov edx,[ebp+12] ;second parameter, ebx should not be altered for C interface
        mul edx  ;edx:eax=eax*edx
...    
Post 07 Apr 2009, 04:04
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.