How to write hello world in assembler under Windows?

前端 未结 8 1050
情书的邮戳
情书的邮戳 2020-11-22 12:01

I wanted to write something basic in assembly under Windows, I\'m using NASM, but I can\'t get anything working.

How to write and compile hello world without the he

8条回答
  •  长情又很酷
    2020-11-22 12:30

    Flat Assembler does not need an extra linker. This makes assembler programming quite easy. It is also available for Linux.

    This is hello.asm from the Fasm examples:

    include 'win32ax.inc'
    
    .code
    
      start:
        invoke  MessageBox,HWND_DESKTOP,"Hi! I'm the example program!",invoke GetCommandLine,MB_OK
        invoke  ExitProcess,0
    
    .end start
    

    Fasm creates an executable:

    >fasm hello.asm
    flat assembler  version 1.70.03  (1048575 kilobytes memory)
    4 passes, 1536 bytes.
    

    And this is the program in IDA:

    enter image description here

    You can see the three calls: GetCommandLine, MessageBox and ExitProcess.

提交回复
热议问题