flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Linking Source with a API-Procedure

Author
Thread Post new topic Reply to topic
ronnie



Joined: 22 Nov 2006
Posts: 5
ronnie
HI,
I wanted to link this source:

Code:
format MS COFF

extrn _Str
extrn '__imp__ExitProcess@4' As ExitProcess:dword
extrn '__imp__MessageBoxA@16' as MessageBox:dword

section '.text' code readable executable

public _4compiler

_4compiler:

        push 5
        call _Str
        
        mov [var],eax
        push 0
        push _S4
        push [var]
        push 0
        call [MessageBox]

;______________________________
        push 0
        call [ExitProcess]
        
        ret


section '.data' Data readable writeable
var dd ?
_S4       db     "Test",0
    


with this one:

Code:
format MS COFF

extrn '__imp__wsprintfA@8' as Convert:dword

section '.text' code readable writeable shareable

public _Str
_Str:

pop edx
pop eax
push edx

push eax
push _S3
push buffer
call [Convert]
mov eax,[buffer]        ;<- here's the error to my mind
ret 

section '.data' Data readable writeable
_S3       db     "%d",0
buffer       dd ?
    


I want to know how to transport register between two compiled obj ?

It would be helpfull if you give me links and tutorials about writing and calling procedures in assembly, too Wink

_________________
http://www.4compiler.de
Post 18 Jan 2007, 19:51
View user's profile Send private message Reply with quote
Kain



Joined: 26 Oct 2003
Posts: 108
Kain
ronnie wrote:
HI,
I wanted to link this source:

Code:
format MS COFF

extrn _Str
extrn '__imp__ExitProcess@4' As ExitProcess:dword
extrn '__imp__MessageBoxA@16' as MessageBox:dword

section '.text' code readable executable

public _4compiler

_4compiler:

        push 5
        call _Str
        
        mov [var],eax
        push 0
        push _S4
        push [var]
        push 0
        call [MessageBox]

;______________________________
        push 0
        call [ExitProcess]
        
        ret


section '.data' Data readable writeable
var dd ?
_S4       db     "Test",0
    


with this one:

Code:
format MS COFF

extrn '__imp__wsprintfA@8' as Convert:dword

section '.text' code readable writeable shareable

public _Str
_Str:

pop edx
pop eax
push edx

push eax
push _S3
push buffer
call [Convert]
mov eax,[buffer]        ;<- here's the error to my mind
ret 

section '.data' Data readable writeable
_S3       db     "%d",0
buffer       dd ?
    


I want to know how to transport register between two compiled obj ?


What do you mean by transport register?

You probably want to link these together, if you are using MS Link or Polink, a linker response file looks something like this:
Code:
-heap:0xF4240,0xF4240
-stack:0xF4240,0xF4240
-base:0x4000000
-entry:_4Compiler
-section:.data,RW
-section:.text,ER
-machine:ix86
-subsystem:windows
-nologo
-out:demo.exe
kernel32.lib
user32.lib
str.obj
comp.obj


    


This is assuming your files are called "str.asm" and "comp.asm" change them as necessary.
I see you also use one of the C libraries. I don't know what its called, you'll have to link in that library too.
Also, I believe the C calling convention is different. You have to balance the stack by adding the byte value of all the pushed parameters to ESP.

To link, assuming the linker response file is called "comp.link"

> polink @comp.link

Quote:

It would be helpfull if you give me links and tutorials about writing and calling procedures in assembly, too Wink


Try AoA:
www.artofassembly.com

The book covers everything from low level aspects to high level displays and frames, along with many different calling conventions.

_________________
:sevag.k
Post 19 Jan 2007, 06:21
View user's profile Send private message 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 YouTube, Twitter.

Website powered by rwasa.