威纶通官方论坛

宏指令计算

[复制链接]
发表于 2012-2-28 22:26:54 | 显示全部楼层 |阅读模式
宏指令中的加法计算中
和的寄存器的内容超出了65535时
怎样处理
乘法中也遇到这样的问题
65535+65535=?
65535*65535=?
这些问题怎样处理
发表于 2012-2-29 09:14:13 | 显示全部楼层
这个用int变量,short变量会溢出。
 楼主| 发表于 2012-3-1 20:07:48 | 显示全部楼层
回复 2# mogoo


   
macro_command main()
int B[3]
GetData(B[0], "Local HMI", LW, 010, 1)
B[2]=B[0]+B[1]
SetData(B[2], "Local HMI", LW, 012, 1)

end macro_command


是这个样子吗
 楼主| 发表于 2012-3-1 21:04:29 | 显示全部楼层
好像有问题
 楼主| 发表于 2012-3-1 22:57:35 | 显示全部楼层
macro_command main()
int B[3]
short e[2]
GetData(B[0], "Local HMI", LW, 010, 1)
GetData(B[1], "Local HMI", LW, 012, 1)
GetData(e[0], "Local HMI", LW, 16, 1)
B[2]=B[0]+B[1]
SetData(B[2], "Local HMI", LW, 014, 1)

if b[2]>9999 then
GETBIT(e[0], e[1], 1)
GetData(e[1], "Local HMI", LB, 100, 1)
end if
end macro_command
您需要登录后才可以发帖 登录 | 注册

本版积分规则

回复帖子

Archiver|小黑屋|威纶通官网 ( 粤ICP备06054553号 )

GMT+8, 2024-5-16 21:59

Powered by Discuz! X3.4

© 2001-2023 Comsenz Inc.

快速回复 返回顶部 返回列表