3 ms·
What you actually want is to enable some kind automatic trapping behavior when a section of code is entered so that you can say “this set of math operations sho
by vlovich123 5y ago
What you actually want is to enable some kind automatic trapping behavior when a section of code is entered so that you can say “this set of math operations shouldn’t overflow”. That’s cheaper than what overflow bits get you although entering/exiting such a mode may be equally or more expensive.
The existence of the overflow bits and that overflow continues to remain a common security flaw indicates that there’s a disconnect between the mental model users have when writing this kind of arithmetic (ie they don’t think about it generally and C integer promotion rules don’t do any favors) and how CPU designers imagine you write code.
- scoutt 5y ago> you can say “this set of math operations shouldn’t overflow” This is the same as putting an "if" statement to check for sizes (before or after the operation); the thing that other languages automatically do for you at runtime (with its performance implications). > The existence of the overflow bits and that overflow continues to remain a common security flaw What do you propose for a new CPU architecture/instruction set/register types? How would you implement it? Signed registers? > how CPU designers imagine you write code. Write a program in assembler. You'll be checking carry/overflow bits in no-time.