(8051) Check if a single bit is set

浪尽此生 提交于 2019-12-02 00:19:20

The C here is the 8051's carry flag - called that because it can be used to hold the "carry" when doing addition operations on multiple bytes.

It can also be used as a single-bit register - so (as here) where you want to move bits around, you can load it with a port value (such as P1.7) then store it somewhere else, for example:

MOV C, P1.7
MOV <bit-address>, C

Then later you can branch on it using:

JB <bit-address>, <label>

Some of the special function registers are also bit addressable. I believe its all the ones ending in 0 or 8. Don't have a reference in front of me but you can do something like setb r0.1. That way if you need the carry for something you dont have to worry about pushing it and using up space on your stack.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!