Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: PLCwannabe on March 12, 2021, 02:43:20 PM
-
Is there a way to make BRX ignore divide by zero errors?
-
When a divide-by-zero happens, ST141 ($DivideByZero) bit gets set. So, in the rung immediately following a calculation you could put:
STR ST141
RST ST141
But, then you'd never know. So, you could count the ST141s before you reset it.
-
Kinda. $InhibitErrors (DST39).
Set the appropriate bit of the error you want to ignore. It doesn't really eliminate the error, but it does mask the error/warning flag.
-
Great. So just reset st141 with an always on. I should have thought of that.
-
I can't find a help file on $InhibitErrors (DST39). Where in the help section is the list of the associated bits?
-
@PLCwannabe, I looked for that as well. I don't think we've put that in the Help file.
@BobO, do you have the bit IDs for DST39?
-
$Info, $Warnings, $Errors, and $InhibitErrors are all 32 bit masks of the 32 ST bits that start at ST128. Easiest thing to do is put all of those in a data view, display DSTs in hex, and see which bits turn on for your issue. I think divide by zero is 13, so you should see 0x00002000 (hex) or 8192 (dec) in $Warnings. So setting $InhibitErrors:13 will block it.
I never made it publicly visible, but there are also masks that determine the level of an ST bit, whether it is info, warning, or error. I had planned to make it configurable. Some folks may consider divide by zero perfectly ok, while others view it as show stopping. The plan was to let them adjust it. Sometimes plans are victims of time realities. :o