【发布时间】:2016-04-22 04:12:16
【问题描述】:
我正在 Mac 上学习 32 位汇编,我一直在尝试写入我桌面上的文件。我使用了这段代码:
global _start
section .data
path: db "/Users/jackliu/Desktop/test.txt",0
string: db "hello",0
.len: equ $ - string
section .text
_start:
mov eax, 5
push dword 2
push dword path
sub esp, 8
int 0x80
add esp, 16
mov ebx, eax
mov eax, 4
push dword string.len
push dword string
push dword ebx
sub esp, 4
int 0x80
add esp, 16
mov eax, 1
push 0
sub esp, 12
int 0x80
该文件是空的,它已经存在于我的桌面上。运行后,它根本不会改变文件。
我的代码有什么问题吗?
【问题讨论】:
-
你是对的。在 os x 中,我读到您必须将堆栈与第 16 位对齐,所以这就是我想要做的。我只是根据您的建议尝试过,但没有运气。
-
好的,现在可以正常使用了。谢谢!
标签: macos assembly x86 nasm 32-bit