【发布时间】:2020-06-24 04:54:26
【问题描述】:
我正在尝试在 32 位程序集中创建一个文件,但是在创建文件时,名称仅限于四个字符。我不确定为什么会这样。 这是我的代码;
.section .data
.equ SYS_WRITE, 4
.equ SYS_CREAT, 8
.equ SYS_OPEN, 5
.equ SYS_CLOSE, 6
.equ O_CREAT_WRONLY_TRUNC, 03101
.equ LINUX_SYSCALL, 0x80
name:
.ascii "t.txt\0"
.section .text
.global _start
_start:
movl %esp, %ebp
pushl name
movl $SYS_OPEN, %eax
movl %esp, %ebx
movl $O_CREAT_WRONLY_TRUNC, %ecx
movl $0666, %edx
int $LINUX_SYSCALL
movl %eax, %esi
movl $SYS_CLOSE, %eax
movl %esi, %ebx
int $LINUX_SYSCALL
movl $1, %eax
int $LINUX_SYSCALL
并通过终端编译代码;
as --32 touchfile.s -o touchfile.o
ld touchfile.o -o touchfile -m elf_i386
./touchfile
【问题讨论】: