NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: namea on June 27, 2011, 08:35:28 AM
-
hello.
i'm trying to use nasm on windows7 64bit.
downloaded nasm and also copied a code from example code section of this forum.
but i got error when compiling.
below is picture of error and code.
(http://www.imageupload.org/thumb/thumb_71688.jpg) (http://www.imageupload.org/?d=94EF956D1)
please help me to understand it.
thanks.
-
Works well on Windows 7 32-bit, with NASM 2.10rc6, here is the code I took from you (I modified it a bit):
section .data
msg db "hello world!",0
len equ $-msg
section .text
global ..start
..start: mov edx, len
mov ecx,msg
mov ebx,1
mov eax,4
int 80h
mov ebx,0
mov eax,1
int 80h
I don't think that nasm has a 64bit version of there Assembler, I might be wrong.
try download 2.10rc6 and if it didn't work reply here.
Note: There are many mistakes in this code, try another example, and don't try any example for FASM, since it has a different syntax.
-
Works well on Windows 7 32-bit, with NASM 2.10rc6, here is the code I took from you (I modified it a bit):
wtf? thats a hello world example for linux. look at the int 80h and the setting up of registers for the calls to sys_write and sys_exit.
-
Just a guess but if NASM doesn't support Unicode UTF8 then that would explain the message the OP is getting.
-
I said it assembles well
no you didn't, you said this...
Works well on Windows 7 32-bit
it can be really frustrating for a new asm programmer at the best of times but telling him that a linux example works well on win 7 is just gonna make the poor guy wanna rip his hair out :D what he needs is a nice simple example that runs on win 7
-
I ASSume that the line numbers shown to the left of your code do not appear in the disk file? They're just in the display, right? That would do it! Any sort of a typo would likely cause that error. One of my favorites is:
mob eax, ebx
Joe suggests UTF8. I think that plain ascii, encoded as UTF8, is... plain ascii. If I'm wrong, that could account for it. Save your source code as plain ascii, if your editor gives you a choice. Regular notepad has a habit of saving your text as "test.asm.txt" if you don't tell it otherwise. That doesn't seem to be happening here. (and would give a different error message)... Some editors like to save as ".doc" format by default, which might cause a problem... I think notepad++ is okay(?).
The example you've got is for Linux, and won't run on any version of Windows. It "should" assemble without complaint, though. The command line you've given Nasm will assemble to a 16-bit, flat binary file, which won't run either...
Find an example for Windows. I think a 32-bit Windows example will run on Win64. Something with "MessageBoxA" in it would be a good one to start with. It'll say "extern MessageBoxA" near the top of it, probably. Then you'll want an appropriate command line for Nasm. "nasm -f win32 test.asm", probably (Nasm will create files in several different output formats). That will ("should") create "test.obj". Then you'll need a linker...
Your best bet might be to grab the NASMX package:
http://sourceforge.net/projects/nasmx/files/nasmx-1.0/windows/
That'll have examples in it, and a linker, which you'll need...
That doesn't really explain the error message... I suspect a typo, or maybe your source file is saved in some "weird" format...
I see Mathi's online... I'll bet he's got this solved!
Best,
Frank
-
Joe is right.
i created two files with the same contents and saved one in UTF-8 and the other in ANSI (in Notepad ++)
Just checked the file contents (first line) in unix using object dump. (test2.asm is in UTF-08 and test3.asm in ANSI).
/homes/Mathi:$ head -1 test2.asm | od -c
0000000 357 273 277 s e c t i o n . d a t a
0000020 \r \n
0000022
/homes/Mathi:$ head -1 test3.asm | od -c
0000000 s e c t i o n . d a t a \r \n
0000017
Obviously test3.asm compiles fine.
Those 3 bytes ( somekind of signature ??) was the only difference.
Thanks for the motivation Frank :)
-
Thanks, Mathi! I ain't never seen none of that, notime, nohow. That explains it. So...
1) Figure out how to get your editor to save in ascii.
2) Find a suitable example for Windows.
3) Tell Nasm what output format you want - the output name is probably okay.
4) Find a linker.
5) Soar! :)
Heck of a lot easier in Linux. :)
Best,
Frank
-
Those 3 bytes ( somekind of signature ??) was the only difference.
Yep, that’s the UTF-8 Byte Order Mark (http://en.wikipedia.org/wiki/Byte-order_mark#UTF-8). It can be a bit of a pain, since many Windows apps add it by default when saving UTF-8 encoded text, and often don’t offer a way to remove it. I had the same issue many years back when I wrote a C++ application which had a string containing a pound sign (British pound, not American pound).
-
In addition to the BOM look at the offsets of those characters and the "blank" characters between them which are in reality nul ('\0') characters. That is UCS-2 16-bit encoding (http://en.wikipedia.org/wiki/UTF-16/UCS-2), not UTF-8. UCS-2 (wide character representations as implemented by Microsoft in Windows) is a subset of UTF-16 which simply doesn't handle characters requiring surrogate pairs ( it only handles the Unicode BMP (http://www.unicode.org) ).
-
Can we be a little more civil towards each other? "Shut up" is not an opcode... although I suppose what we're trying to do is get Nasm to "shut up"...
The Unix utility "tail" could perhaps be used to remove this "Byte Order Mark". The rest of it is okay, right? Ports of the Unix utilities are available for Windows, or we could write one (more "fun"), but surely there's an easier way! Unless I'm mistaken, notepad++ is commonly used for source code editing, so there must be a way. This may help:
http://npp-community.tuxfamily.org/documentation/notepad-user-manual/document-properties/encoding
Then maybe we can get on to "suitable example", "output format", and "linker". These three are interrelated, so maybe we first should ask "what linker?". If in doubt, grab that NASMX package, I guess...
Used to be so easy in the good old days! :)
Best,
Frank
-
Unless I'm mistaken, notepad++ is commonly used for source code editing, so there must be a way.
I use Notepad++ quite frequently when in Windows to convert line-ending from Unix (LF) to Windows (CR-LF) and vice-versa. You can also save the file in many different output formats. Use ANSI output format when saving source code files.
Used to be so easy in the good old days! :)
Best,
Unfortunately those days are long gone, my friend. :(
Us old dogs have to learn the new tricks ;D
-
thank u all.
yes. it was unicode/ansi issue.
now compiling works.
so learning so far...