NASM Forum > Using NASM

Linking and compiling my frst x64 asm code

(1/4) > >>

Jaafar:
Hi dear asm community,

Info: I am running Windows10 x64bit .

I am a newbie and want to start learning to code in assembly.

I have installed nasm.exe and and have written my first console "hello world" code in asm (code snippet copied from the internet) BUT I can't for the life of me link or compile the file. The cmd prompt keeps saying can't recognize the commands.

I have spent 2 entire days trynig to link and compile the asm code but without any luck. This is so frustrating as I just want to dive into writing asm code.

Can anyone please guide me step by step ?

Regards.



Frank Kotler:
Hi Jaafar,

Welcome to the forum.

Good start telling us what OS  you're running! Next, you will probably have to tell us which linker you're using (or trying to use). "Golink" is pretty popular, "ld" is available, Microsoft's "link" will work -  you want the "incremental" version, not the "segmented" version... Maybe others(?).
 
Maybe I shouldn't mention this, but others in your position have gotten ahold of a Linux snippet and are trying to use that on Windows - won't work...

So... good start, but keep telling us what you tried and what happened. Nasm will do a lot of different things, and linkers too...

I haven't run Windows for a long time, but surely someone will be able to help you.

Best,
Frank

Jaafar:
Hi Frank. Thanks for replying.

I donwloaded and installed GoLink.exe but I don't know how to use it. I am a complete beginner.

Do I need to place the Golink.exe in the same folder as the nasm.exe ? do I need to add any folders to the windows environnement variable Path ? and what about compiling ?

I wish I could find a step by step guide for dummies.

Thanks again.

Frank Kotler:
Hi again Jaafar,

We may need to create that step by step guide.

We were all complete beginners at one time. That can be fixed.

I am old and tired, My memory is all shot... among other things. That may not be so easy to fix.

I KNOW I have seen simple examples right on this forum... but can't find 'em right now.

Where did you find the code? Any help there?

You shouldn't need to put Golink in the same folder as Nasm. You will want to put them both on your path. That's one step.

Assemble with "nasm -f win64 myfile.asm". Other options are possible but probably not necessary. That's one step.

Now... "golink /console myfile.o ... some more stuff" :) That should do it. The "more stuff" might be like :"user64.dll"? Maybe :"kernel64.dll"? Sorry I can't be more help there.

It gets easier after the first time. But you know that, that's what you're asking... If you don't get any help with Golink, fool with it 'til it works, :) Show us more of what you did, if you need to.

Best,
Frank

debs3759:
Please post the code you are struggling with, as that may help us determine what the problem is. For example, 16-bit code won't run in a 64-bit Windows console.

Navigation

[0] Message Index

[#] Next page

Go to full version