C 语言实现中的 PowerPC stb 指令

问题描述 投票:0回答:1

我正在尝试将整数的高24-32字节存储到char指针地址,即

stb r9 0(r30)

如何使用C实现这个行为?

powerpc
1个回答
0
投票

在 C 中,您不需要对存储进行编程 - 这是底层汇编器实现的工作。但如果你说你需要将 32 位变量

var
的高 8 位保存到指针
p
中存储的某个地址,那么这只是普通位掩码的工作

*p = (var & 0xFF000000);
/*
*p                dereference p, i.e., do this to the address stored in p
=                 assign the value on the right to what is on the 
                  left (i.e., the reference to the address stored in p)
var & 0xFF000000  Take the bit-wise AND of the value in `var` and 0xFF000000
*/
© www.soinside.com 2019 - 2024. All rights reserved.