NASM hello world
时间: 2023-08-24 10:06:13 浏览: 56
Sure! Here's an example of a NASM program that prints "Hello, World!" to the console:
```assembly
section .data
msg db 'Hello, World!', 0
section .text
global _start
_start:
; write the message to stdout
mov eax, 4
mov ebx, 1
mov ecx, msg
mov edx, 13
int 0x80
; exit the program
mov eax, 1
xor ebx, ebx
int 0x80
```
This program uses the NASM syntax and Linux system calls. It first defines a `msg` variable in the `.data` section, which stores the string "Hello, World!". Then, in the `.text` section, it uses the `write` system call to print the message to the console. Finally, it uses the `exit` system call to terminate the program.
To assemble and run this program, you can save it to a file named `hello.asm` and use the following commands:
```
nasm -f elf hello.asm
ld -m elf_i386 -s -o hello hello.o
./hello
```
This will compile and run the NASM program, and you should see "Hello, World!" printed to the console.
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)