仅修改存储单元的LSB
是否可以编写一系列指令,将 1 放入地址 B3 处存储单元的最低有效位,而不干扰存储单元中的其他位?
我指的机器指令是 STOP、ADD、SWITCH、STOP、LOAD、ROTATE 等。
Is it possible to write a sequence of instructions that will place a 1 in the least significant bit of the memory cell at address B3 without disturbing the other bits in the memory cell?
The machine instructions I am referring to is the STOP, ADD, SWITCH, STOP, LOAD, ROTATE etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
澄清:这个问题最初被标记为C#;因为不是OP重新标记它,所以我将把它留在这里,直到OP的意图更清楚为止。
C# 是一种高级编程语言,它编译为 IL,而不是机器代码。因此:不,绝对不存在用于执行特定机器代码操作的支持机制(即使有,它也不可能在语言之间移植)。
您可以使用基于整数的类型上的运算符来执行高级位操作;如果您真的想要编写IL,可以手动构建它(ilasm),或者在运行时通过
DynamicMethod
/ILGenerator
- 但这些仍然只处理 CIL 操作码,不处理机器代码。Clarification: this question was originally tagged C#; since it wasn't the OP that re-tagged it, I'll leave this here until the OP's intentions are clearer.
C# is a high-level programming language, which compiles down to IL, not machine code. As such: no, there is absolutely no supported mechanism for performing specific machine code operations (and even if there were, it couldn't possibly port between langauges).
You can do high level bit operations, using the operators on the integer-based types; and if you really want you can write IL, either building it manually (ilasm), or at runtime via
DynamicMethod
/ILGenerator
- but these still only deal with CIL opcodes, not machine codes.我认为用 1 进行“或”运算就可以完成任务,不是吗:
算法:
字节= [0xB3 处的数据]
字节=字节| 0x01
这对我开发 8051 MCU 来说效果很好。
I think ORing it with 1 will do the job ain't it:
algo:
byte= [data at 0xB3]
byte = byte | 0x01
this works fine with me in developing for 8051 MCUs.