【发布时间】:2012-12-19 07:41:48
【问题描述】:
section .data
msg: db 'Hello World di Simona',10 ;the message to write
len: equ $ - msg ;length of the message
section .text
global _start
_start:
mov edx, len ;save the length
mov ecx, msg ;save the message to display
mov ebx, 1 ;prepare for the system call
mov eax, 4
int 0x80 ;sytem call
第一个问题:当我使用链接器时,我收到此警告“-macosx_version_min 未指定,假设为 10.7”,我该如何避免它?
第二个问题:一切顺利,直到我运行可执行文件,我收到此错误“分段错误:11” 这是什么意思?这段代码有什么问题?
附加信息:我在 Mac OS X 下使用 nasm,搭配 Intel Core 2 Duo,今天我上第一节汇编课,所以我是这门语言的新手。
【问题讨论】:
-
1.指定 -macosx_version_min 怎么样? 2a.分段错误意味着您试图访问您无权访问的内存。 2b。在调试器下运行程序,查看分段错误发生的位置以及您尝试访问的内存。
-
int 0x80后面是什么?如果这些成功(而且看起来应该),之后会发生什么? -
这看起来像 32 位 linux 风格的系统调用。我认为 mac osx 使用完全不同的方式来执行系统调用。