如何编写的Hello World用汇编语言在Windows下? [英] How to write hello world in assembler under Windows?

查看:641
本文介绍了如何编写的Hello World用汇编语言在Windows下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写Windows下的东西基本都在组装,我使用NASM,但我不能得到任何工作。

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

如何编写和编译的Hello World无C函数在Windows的帮助?

How to write and compile hello world without the help of C functions on Windows?

推荐答案

NASM范例

; ----------------------------------------------------------------------------
; helloworld.asm
;
; This is a Win32 console program that writes "Hello, World" on one line and
; then exits.  It needs to be linked with a C library.
; ----------------------------------------------------------------------------

    global  _main
    extern  _printf

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

然后运行

nasm -fwin32 helloworld.asm
gcc helloworld.obj
a

还有无能新手指南的Hello World在NASM 不使用C ++类库。然后,code是这样的。

There's also The Clueless Newbies Guide to Hello World in Nasm without the use of a C library. Then the code would look like this.

org 100h
mov dx,msg
mov ah,9
int 21h
mov ah,4Ch
int 21h
msg db 'Hello, World!',0Dh,0Ah,'$'

祝你好运。

这篇关于如何编写的Hello World用汇编语言在Windows下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆