在OSX 64位NASM问题 [英] NASM issue on OSX 64-bit

查看:283
本文介绍了在OSX 64位NASM问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学习ASM和​​我有一个小问题。 我不能声明多个字符串section.data。 我想是这样的:

I'm learning ASM and I have a small problem. I can't "declare" more than one string in "section.data". I'm trying something like this:

section .data
    string1 db "test1 ", 0;
    string2 db "test2 ", 0;
section .text
    global _test
    extern _puts
    _test:
         lea rdi, [rel string1]
         call _puts
         lea rdi, [rel string2]
         call _puts
         ret

此功能应该打印测试1测试2的标准输出,但它不工作。 其结果是:

This function is supposed to print "test1 test2 " on STDOUT, but it doesn't work. The result is:

test2

这仅适用于存储在最后一个字符串!如果有人知道为什么,请告诉我!

It only works for the last string stored! If someone know why, please tell me!

推荐答案

如果您使用的是 NASM 零八年十一月二号,有记录了问题的此处做相对寻址结合在数据段中的多个条目。

If you're using nasm 2.11.08, there is a issue documented here to do with relative addressing combined with multiple entries in the data section.

您可以做两件事情之一(或两者)是一定的。

You can do one (or both) of two things to be certain.

首先,你可以看一下生成的汇编code,调查一下它的的实际上的翻腾出来。这可能是最终选择,因为你就可以清楚地看到CPU会是怎样运行的。

First, you can have a look at the generated assembler code to investigate what it's actually churning out. That's probably the definitive option since you can then see exactly what the CPU will be running.

其次,你可以用的前面的版本 NASM 的测试code,看看问题是否消失。如果是这样,这是间接证据,它的错误在08年11月2日导致你的问题。

Second, you can test your code with an earlier release of nasm to see if the problem goes away. If so, that's indirect evidence that it's the bug in 2.11.08 causing your issues.

这篇关于在OSX 64位NASM问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆