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

Title: Divide by zero errors.
Post by: PLCwannabe on March 12, 2021, 02:43:20 PM
Is there a way to make BRX ignore divide by zero errors?
Title: Re: Divide by zero errors.
Post by: Greg on March 12, 2021, 03:24:08 PM
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.
Title: Re: Divide by zero errors.
Post by: BobO on March 12, 2021, 03:29:48 PM
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.
Title: Re: Divide by zero errors.
Post by: PLCwannabe on March 12, 2021, 03:40:14 PM
Great. So just reset st141 with an always on. I should have thought of that.
Title: Re: Divide by zero errors.
Post by: PLCwannabe on March 13, 2021, 08:48:06 AM
I can't find a help file on $InhibitErrors (DST39). Where in the help section is the list of the associated bits?
Title: Re: Divide by zero errors.
Post by: Greg on March 13, 2021, 08:55:34 AM
@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?
Title: Re: Divide by zero errors.
Post by: BobO on March 13, 2021, 10:19:43 AM
$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