Hi!
Am 17.08.23 um 22:13 schrieb Michael A Hawkins:
Hello SDCC users,
I am sure this has been discussed before. So I apologize in advance for
repeating it.
With assembler, you can test for a reg/mem operation over/under flow by
checking the carry flag.
So for C, when overflows are involved, I have always used larger
variables. For 8 bit, use 16 bit. For 16, use 32. Then greater/less than
tests can be used looking for quasi over flow. But that's wasteful.
How do you check over/underflow in C without wasting memory?
/Mike
You could e.g. use the brand new C23 functionality for checked integer
arithmetic from stdckdint.h.
Greetings,
Benedikt
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user