NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on March 08, 2005, 12:33:35 PM
-
Hi
I'm a newbie to NASM.
I have sample c program and i did generate assembly file
from gcc in intel mode.
%gcc -masm=intel sample.c
When i try to generate object code from NASM it fails with parsing errors.
I tried to use A2I tool to convert AT&T syntax to
Intel.It didn't help either.
Does anybody know what coudl be the problem.
bw
John
-
Hi John,
There are differences between Nasm syntax and what gcc/gas consider "Intel syntax". The "converters" - I've used intel2gas more than A2I - take care of much of the "grunt work", but typically require some "hand editing" before the results will assemble properly with Nasm. I don't imagine using *both* "-masm intel" and a "converter" will work.
Take a close look at the lines Nasm is complaining about. You *may* be able to just comment 'em out, if you're lucky. If they're a vital part of the code, you'll have to figure out what the code *has* to do at that point (to work as intended), and then figure out what syntax will persuade Nasm to do that. In most cases, this isn't as hard as it sounds - you might need to RTFM or look at more Nasm examples to learn Nasm's ways...
Or, post the offending lines here - we can probably help you get Nasm to swallow 'em. Hard to say just what the problem is without more information.
Best,
Frank
-
Dear all:
I converted gcc produced *.S files to NASM by att2intel.
But I found that it can't convert function declaraction or some psudo instructions?
such as :
.globl function1 (can't convert )
or
.align 16
(which converted by att2intel to .align 65536,and I wonder is it right?)
rounding_512 : .fill 4,4,512 (can't convert also!)
So I rewrite by hand as following:
rounding_512 : dw 512 512 512 512 512 512 512 512
So, could anyone tell me how to declare a function in nasm? Is it the same way as MASM? (PROC and ENDP) Thanks.
-
Hi Kabbin,
> I converted gcc produced *.S files to NASM by att2intel.
> But I found that it can't convert function declaraction or some psudo
> instructions?
> such as :
> .globl function1 (can't convert )
That's surprising. I'd have expected that to convert "easily" to "global function1"...
> or
> .align 16
> (which converted by att2intel to .align 65536,and I wonder is it right?)
I don't think so. I'd expect just "align 16".
> rounding_512 : .fill 4,4,512 (can't convert also!)
> So I rewrite by hand as following:
> rounding_512 : dw 512 512 512 512 512 512 512 512
I'm not familiar with "fill", but something I saw recently suggested that the second parameter was "size"... so you might want "dd" rather than "dw"? If you get unexpected results, try that.
> So, could anyone tell me how to declare a function in nasm? Is it the same way
> as MASM? (PROC and ENDP) Thanks.
You'll have to "%include" a macro file if you want "proc" and "endp". There are several in the "misc/" directory that have it. If you want to export a function from a shared library, "global myfunc:function" (elf only).
Best,
Frank