linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* simple hello.asm (NASM) not compile in x64, plz help
@ 2014-11-29  4:35 eric lin
  2014-11-29  5:26 ` Brian Raiter
  2014-12-24 19:49 ` Robert Plantz
  0 siblings, 2 replies; 4+ messages in thread
From: eric lin @ 2014-11-29  4:35 UTC (permalink / raw)
  To: linux-assembly

hello:
I copied a simple hello.asm  (NASM) assembly program from 
www.tldp.org/HOWTO/html_single/Assembly-HOWTO/
try to compile and run on my linux 64(ubuntu14.04), but I got errors:

-------------------------------------

ld -s -o heworl heworl.o 
ld:i386 architecture of input file *.o is incompatible with i386:x86-64 output
-------------------------------------------------
please help,(how to make it compile and run on my 64 platform rather than ask me switch to 32 bit platform),thanks a lot ina dvance, eric

_____________________________________________________________
Luxmail.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: simple hello.asm (NASM) not compile in x64, plz help
  2014-11-29  4:35 simple hello.asm (NASM) not compile in x64, plz help eric lin
@ 2014-11-29  5:26 ` Brian Raiter
  2014-12-24 19:49 ` Robert Plantz
  1 sibling, 0 replies; 4+ messages in thread
From: Brian Raiter @ 2014-11-29  5:26 UTC (permalink / raw)
  To: linux-assembly; +Cc: fsshl

> 
> ld -s -o heworl heworl.o 
> ld:i386 architecture of input file *.o is incompatible with i386:x86-64 output

You told nasm to create a 32-bit .o file. Tell nasm to create a 64-bit
.o file instead. Use "-f elf64" instead of "-f elf32".

The command "nasm -hf" will display all the valid output formats that
nasm supports.

b

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: simple hello.asm (NASM) not compile in x64, plz help
  2014-11-29  4:35 simple hello.asm (NASM) not compile in x64, plz help eric lin
  2014-11-29  5:26 ` Brian Raiter
@ 2014-12-24 19:49 ` Robert Plantz
  1 sibling, 0 replies; 4+ messages in thread
From: Robert Plantz @ 2014-12-24 19:49 UTC (permalink / raw)
  To: 'fsshl@luxmail.com', 'linux-assembly@vger.kernel.org'

(Note: I originally sent this message on Nov. 29, but the server bounced it because my email client included some HTML. I'm trying again here. I apologize if this is a duplicate for you.)

If you’re interested in using the gnu programming environment, I have written an introductory textbook on the topic. You can get more information at http://bob.cs.sonoma.edu/. I sell it at lulu.com, but you can download a preview copy (first seven chapters) for free from my website. It’s specifically about the 64-bit platform.

--Bob Plantz


-----Original Message-----
From: linux-assembly-owner@vger.kernel.org [mailto:linux-assembly-owner@vger.kernel.org] On Behalf Of eric lin
Sent: Friday, November 28, 2014 8:36 PM
To: linux-assembly@vger.kernel.org
Subject: simple hello.asm (NASM) not compile in x64, plz help

hello:
I copied a simple hello.asm  (NASM) assembly program from www.tldp.org/HOWTO/html_single/Assembly-HOWTO/
try to compile and run on my linux 64(ubuntu14.04), but I got errors:

-------------------------------------

ld -s -o heworl heworl.o
ld:i386 architecture of input file *.o is incompatible with i386:x86-64 output
-------------------------------------------------
please help,(how to make it compile and run on my 64 platform rather than ask me switch to 32 bit platform),thanks a lot ina dvance, eric

_____________________________________________________________
Luxmail.com
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* simple hello.asm (NASM) not compile in x64, plz help
@ 2014-11-29 10:20 Charles T. Bell
  0 siblings, 0 replies; 4+ messages in thread
From: Charles T. Bell @ 2014-11-29 10:20 UTC (permalink / raw)
  To: linux-assembly

[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]



On 11/29/2014 12:26 AM, Brian Raiter wrote:
>>
>> ld -s -o heworl heworl.o
>> ld:i386 architecture of input file *.o is incompatible with
i386:x86-64 output
>
> You told nasm to create a 32-bit .o file. Tell nasm to create a 64-bit
> .o file instead. Use "-f elf64" instead of "-f elf32".
>
> The command "nasm -hf" will display all the valid output formats that
> nasm supports.
>
> b
> --
> To unsubscribe from this list: send the line "unsubscribe
linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

I normally use gold (linker) and yasm (like nasm) since they are more
64-bit friendly.
My Makefile is thus:

hello: hello.o
	gold hello.o -o hello
hello.o: hello.asm
	yasm -f elf64 -g dwarf2 -o hello.o hello.asm

You can use the entries individually or just copy and paste into your
own Makefile and type: make
That will make .o file and link it for the executable, but don't forget
to rename "hello" to "heworl" in every instance, so it will have the
name you chose.
Hope this help!

Tom
-- 
"To argue with a man who has renounced the use of
reason is like administering medicine to the dead."
-- Thomas Paine, The American Crisis No. V(1776)

[-- Attachment #2: cbell44.vcf --]
[-- Type: text/x-vcard, Size: 149 bytes --]

begin:vcard
fn:Tom
n:Bell;Charles
email;internet:charles.bell.us@member.mensa.org
tel;home:386-673-8327
tel;cell:386-212-5407
version:2.1
end:vcard


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-24 19:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-29  4:35 simple hello.asm (NASM) not compile in x64, plz help eric lin
2014-11-29  5:26 ` Brian Raiter
2014-12-24 19:49 ` Robert Plantz
2014-11-29 10:20 Charles T. Bell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).