分享

威纶通触摸屏宏指令介绍(八)

 ifelser3b283ul 2018-12-19


★位状态转换

函数名称 GETBIT
语法 GETBIT(source, result, bit_pos)
描述 获取数据或者变量 (source) 指定的位的状态,并将结果放置在 result 变量中。
result 的数据将为 1 或者 0
source bit_pos 可以是常数或者变量,但是 result 必须为变量。
举例 macro_command main()
int source, result
short bit_pos
source = 4
bit_pos = 2
GETBIT(source, result, bit_pos) // result is 1
end macro_command

举个栗子:在软件里面建立如下的元件,三个数值,一个功能键


在宏指令里面编辑指令

实验结果,十进制的146的bit4位和bit1位为1,当获取相应的bit位是,显示为1

说明:此处的get  相当于读取的意思,即看看该位的状态,

下面的SETBITON和SETBITOFF中的set 相当于写入 ;

SETBITON==SET (设置)  BIT (位)  ON  (1),将某位置位为1

SETBITOFF==SET (设置)  BIT (位)  OFF(0),将某位置位为0

函数名称 SETBITON
语法 SETBITON(source, result, bit_pos)
描述 将数据或者变量 (source) 指定的位地址设置为 1,并将改变后的数据存放在 result
变量中。
source bit-pos 可以是常数或者变量,但是 result 必须为变量。
举例 macro_command main()
int source, result
short bit_pos
source = 0
bit_pos = 2
SETBITON (source, result, bit_pos) // result is 4
end macro_command



函数名称 SETBITOFF
语法 SETBITOFF(source, result, bit_pos)
描述 将数据或者变量 (source) 指定的位地址设置为 0,并将改变后的数据存放在 result
变量中。
source bit-pos 可以是常数或者变量,但是 result 必须为变量。
举例 macro_command main()
int source, result
short bit_pos
SETBITOFF(9, result, 3) // result is 1
source = 4
bit_pos = 2
SETBITOFF(source, result, bit_pos) // result is 0
end macro_command

INVBIT == INV  bit   将某位取反

函数名称 INVBIT
语法 INVBIT(source, result, bit_pos)
描述 将数据或者变量 (source) 指定的位地址状态相反,并将改变后的数据存放在 result
变量中。
source bit-pos 可以是常数或者变量,但是 result 必须为变量。
举例 macro_command main()
int source, result
short bit_pos
INVBIT(4, result, 1) // result = 6
source = 6
bit_pos = 1
INVBIT(source, result, bit_pos) // result = 4
end macro_command

举个栗子:

实验结果:

十进制数146的二进制形式为1001 0010,将其bit4取反,得到1000 0010



    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多