0

I've started learning Assembly, and I have two files:

File main.c

#include <stdio.h>

int assembly(void);

int main(void)
{
    printf("Resultado: %d\n", assembly());
    return 0;
}

and

File assembly.asm

global assembly
assembly:
  mov eax, 777
  ret

So I used this command "nasm assembly.asm -f elf64" and it created the file "assembly.o". After that, I used another command "gcc -c main.c -o main.o", but it showed some errors on the shell:

Errors on shell

What can I do?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 1
    Means you have some nonprintable characters in your C file. Maybe the editor you used put fancy unicode quotes. Make sure it's saved as plain ascii. – Jester Mar 23 '20 at 22:32
  • 1
    copy/paste your errors from the shell as text, not an image, in case someone else is searching and happens to have the same non-ASCII characters and searches on `stray '\213' in program` instead of on your title. Also, notice that this is your C source, and has nothing to do with NASM. You haven't even put your NASM-output `.o` on the command line, like `gcc -g -Wall main.c asm.o -o program` to compile + link in one step – Peter Cordes Mar 24 '20 at 00:01
  • `cat -A main.c` should show you the nonprintable characters. – Keith Thompson Mar 24 '20 at 00:18
  • How did you enter the source code, which program did you use? – the busybee Mar 24 '20 at 06:59
  • The error message is *** *** *** *** *** *** ***unsearchable*** *** *** *** *** *** *** due to the image. Please review *[Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/)* (e.g., *"Images should only be used to illustrate problems that* ***can't be made clear in any other way,*** *such as to provide screenshots of a user interface."*) and [do the right thing](https://stackoverflow.com/posts/60822148/edit) (it covers answers as well). Thanks in advance. – Peter Mortensen May 04 '23 at 21:01
  • Fortunately, it is common and well known. 342 200 213 (octal) → 0xE2 0x80 0x8B (hexadecimal) → UTF-8 sequence for Unicode code point U+200B ([ZERO WIDTH SPACE](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8192&number=128)). It can be searched for (and replaced) using the regular expression `\x{200B}` in any modern text editor or IDE (note: The notation is different in Visual Studio Code (and probably others): `\u200B` (instead of `\x{200B}`)). – Peter Mortensen May 04 '23 at 21:04
  • This is a ***very*** common error when copying code from web pages, [PDF](https://en.wikipedia.org/wiki/Portable_Document_Format) documents, through chat (e.g. [Skype Chat](https://en.wikipedia.org/wiki/Features_of_Skype#Skype_chat) or [Facebook Messenger](https://en.wikipedia.org/wiki/Facebook_Messenger)), etc. The canonical question is *[Compilation error: stray ‘\302’ in program, etc.](https://stackoverflow.com/questions/19198332)*. – Peter Mortensen May 04 '23 at 21:05

0 Answers0