【发布时间】:2013-11-14 14:40:18
【问题描述】:
这段代码在屏幕上打印Hello
.data
hello: .string "Hello\n"
format: .string "%s"
.text
.global _start
_start:
push $hello
push $format
call printf
movl $1, %eax #exit
movl $0, %ebx
int $0x80
但如果我从 hello 字符串中删除 '\n',如下所示:
.data
hello: .string "Hello"
format: .string "%s"
.text
.global _start
_start:
push $hello
push $format
call printf
movl $1, %eax #exit
movl $0, %ebx
int $0x80
程序不工作。有什么建议吗?
【问题讨论】:
-
定义“不起作用”.
-
它不打印“Hello”
-
你确定它不会被你的shell提示符覆盖吗?如果你使用一个很长的字符串(但仍然没有
\n)怎么办? -
长字符串不起作用,我确信它不会打印任何东西。我只是尝试在室友电脑上运行这两种变体,但都没有成功。
-
@迈克尔。我正在使用
gcc -nostartfiles filename命令编译代码。