SPARC大会问题 [英] SPARC Assembly question

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

问题描述

我想在我的C程序中编写一个非常简单的内联汇编例程,该例程不执行任何操作 否则,将本地寄存器%l0-%l7设置为不同的值.我尝试了以下简单的方法:

I wanna write a very simple inline assembly routine in my C program which does nothing else then setting the local registers %l0 - %l7 to different values. I tried the following straightforward approach:

asm volatile (
    ".text\n\t"
    "mov 0, %%l0             \n\t"
    "mov 1, %%l1             \n\t"
    "mov 2, %%l2             \n\t"
    "mov 3, %%l3             \n\t"
    "mov 4, %%l4             \n\t"
    "mov 5, %%l5             \n\t"
    "mov 6, %%l6             \n\t"
    "mov 7, %%l7             \n\t"
);  

不幸的是,汇编器告诉:每条指令的操作数非法.有人可以这么高兴向我指出如何正确地将立即值传递给SPARC汇编程序吗?

unfortuantely, the assembler tells: illegal operand for each instruction. Could somebody please be so nice to point me out how I can properly pass immediate values to the SPARC assembler?

非常感谢!

谢谢克里斯,我进行了您建议的更改,但Sparc编译器仍然告诉您一些有关非法操作数的信息...

Thanks Chris, I made the changes you suggested but the Sparc compiler still tells some something about illegal operands...

推荐答案

SPARC并不具有这样的立即移动"指令;有一个or可以像or %g0, 123, %l0一样使用(或者使用零寄存器%g0使用不超过11​​位的常数,从而将该常数移到目标寄存器中),或者sethi指令,可用于设置寄存器的 upper 21位.为了容纳 any (32位)常量,因此必须合成两步式set,首先对高位进行sethi,然后对低位进行or.

SPARC doesn't mave "immediate move" instructions as such; there's either or which can be used like or %g0, 123, %l0 (or'ing a no-more-than 11-bit constant with the zero register, %g0, resulting in moving said constant into the target register), or the sethi instruction that can be used to set the upper 21 bits of a register. In order to accommodate any (32bit) constant, you therefore have to synthesise a two-step set by doing a sethi first for the upper bits followed by an or with the lower ones.

SPARC汇编程序通常知道创建该序列的set ..., %tgtregister快捷方式,和/或在常数适合的情况下消除一条指令.

SPARC assemblers usually know a set ..., %tgtregister shortcut to create this sequence, and/or eliminate one instruction should the constant be fit for that.

还请注意,在64位/sparcv9中,set指令最终可能会评估为最多5条指令的序列,从而将事物移位/或移位.

Also note that in 64bit / sparcv9, the set instruction may ultimately evaluate to a sequence of up to five instructions, shifting/or'ing things together.

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

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