I wrote this code (the file is called hello.asm):

global _main extern _printf section .text _main: push message call _printf add esp, 4 ret message: db 'Hello, World', 10, 0 

But it gives errors and the message must be in segments block

How to solve them?

System: windows 7, 32 bit architecture.

enter image description here

  • Which command is used to compile? Please indicate the full compilation line - yeputons
  • one
    The following command is used for compilation: C:\masm32\bin> ml.exe hello.asm - Ilnyr

1 answer 1

You use to compile MASM (Macro Assembler from Microsoft), but the code is written in the syntax for another assembler (in general, there are many different syntaxes). In particular, exactly this syntax uses NASM . After installing NASM, you can compile your code with two commands:

 nasm -f win32 hello.asm link hello.obj msvcrt.lib