【发布时间】:2022-08-19 19:39:11
【问题描述】:
我在 debian linux 下用汇编写了一个简单的“Hello world”:
; Define variables in the data section
SECTION .data
hello: db \'Hello world!\',10
helloLen: equ $-hello
; Code goes in the text section
SECTION .text
GLOBAL _start
_start:
mov eax,4 ; \'write\' system call = 4
mov ebx,1 ; file descriptor 1 = STDOUT
mov ecx,hello ; string to write
mov edx,helloLen ; length of string to write
int 80h ; call the kernel
; Terminate program
mov eax,1 ; \'exit\' system call
mov ebx,0 ; exit with error code 0
int 80h ; call the kernel
组装后
nasm -f elf64 hello.asm -o hello.o ld -o hello hello.o.我有一个9048字节二进制。
然后我在代码中更改了两行:从
.data到.DATA和.text到.TEXT:SECTION .DATA SECTION .TEXT并得到了一个4856字节二进制。
将它们更改为SECTION .dAtA SECTION .TeXt制作了一个4856字节二进制也是。
NASM 被声明为不区分大小写的编译器。那有什么区别呢?
-
NASM 肯定是不是不区分大小写。
标签: linux assembly compiler-construction nasm binary-size