Author Topic: cross assembling?  (Read 8072 times)

nobody

  • Guest
cross assembling?
« on: January 12, 2008, 07:48:54 AM »
What is the default platform nasm compiles for??
How can i produce code for an i586 system but running on an amd 64bit system??

nobody

  • Guest
Re: cross assembling?
« Reply #1 on: January 12, 2008, 08:42:59 AM »
What is the default platform nasm compiles for??

NONE. Depends from YOUR code. 8086, 80386, XX64-XX (crap)

> cross assembling?

NO. (your problem is NOT CROSS'ed)

> produce code for an i586 system but running on an amd 64bit system??

Since you didn't reveal your host OS, I assume it's DOS, DOS will work on AMD-64 and NASM works under DOS, just code for i586 then. ;-)

But you can compile NASM for "ARM" or whatever ... and then cross from there, if you really insist to do :-D

nobody

  • Guest
Re: cross assembling?
« Reply #2 on: January 12, 2008, 10:04:46 AM »
Ahhhh... Nasm's default output format is flat binary. That's usually used to create a  dos .com file, but can be used to create PE or ELF executables as well. So I guess the default platform is "any of 'em". :)

You'd select between 32- and 64-bit output with "-f win32", "-f win64", "-f elf32", "-f elf64" - or if by some madness you're doing this in "-f bin", a "bits 32" or "bits 64" directive.

By default, Nasm will accept any valid instruction you type. If you want Nasm to prevent you from using any instruction beyond a certain CPU level, the "cpu" directive will do that. You'd want "cpu 586", I guess. (never used it)

You may need to inform your (64-bit?) linker that you intend a 32-bit target. Mmmm... something like "-march=i386" or so for ld - dunno if "586" is an option. RTFM for your linker, if all else fails. :)

Never done it, but I think that's what you'd want to do.

Best,
Frank