Re: Problem with fasm



suchi_01 wrote:
Hi All,
There is a complicated issue here. I have downloaded
fasm source of a driver and want to integrate it to my kernel.
However, there is a problem:

1. If i call a FASM function from within C code (kernel), it is not
able to return back to the next line in C Code

What *does* it do?

2. If i call a NASM function from within C Code, it works properly (it
returns back to next line in C Code)

Here are the code snippets:

NASM:

global <func name>

<func name>:
ret


FASM:

public <func name>

<func name>:
ret


Is there a global keyword or similar stuff in FASM?

"public", AFAIK. We need to tell Fasm a "format", too (in the source, not on the command line like Nasm). As a test, I just "converted" a Nasm demo I had to Fasm (just added "format elf", changed "global" to "public" and fixed up the section declaration). Worked fine. The only issue I can see is that I don't think Fasm supports OMF. What format are you using?

Best,
Frank

;---------------
format elf

public getvendor

section ".text" executable
getvendor:
pusha
xor eax, eax
cpuid
mov eax, [esp + 36]
mov [eax], ebx
mov [eax + 4], edx
mov [eax + 8], ecx
mov byte [eax + 12], 0
popa
xor eax, eax
ret
;-----------------

And the C caller...

#include <stdio.h>

void getvendor(char *vendorbuf);

int main(void)
{char vendorbuf[13];
getvendor(vendorbuf);

puts(vendorbuf);
return 0;
}

.



Relevant Pages

  • Re: Blueflops ate my X
    ... problems with my FASM assembled code, although I have managed to segfault FASM itself, a few times, and it is far too easy to get it to complain about being unable to generate an output file. ... mov eax, 4 ... xor eax, eax ... or assembling with Nasm, for that matter... ...
    (alt.lang.asm)
  • Benchmarking RosAsm vs. FASM
    ... RosAsm is the "fastest of all actual assemblers." ... compilation time against FASM compiling FRESH. ... uses this scheme as a benchmark). ... mov al, byte ...
    (alt.lang.asm)
  • Problem with FASM
    ... If i call a FASM function from within C code (kernel), ... returns back to next line in C Code after assembling assembly code) ... global <func name> ...
    (alt.lang.asm)
  • Re: Calculating checksums...
    ... Seriously though, NASM is an excellent assembler, however ... the tip of the FASM iceberg. ... This NASM source generates a "hello world" program padded to ... mov cx,size ...
    (alt.lang.asm)
  • Problem with fasm
    ... If i call a FASM function from within C code (kernel), ... global <func name> ...
    (comp.lang.asm.x86)