Underflow catching

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to do something similar to

if ((current-array_size)<0) first_sample=0;
else first_sample = current-array_size;

But it is inefficient (even with optimization) and doesn't work with unsigned variables.
However I know that the check and zeroing can be done very easily at the end before storing the registers to the RAM with a single negative status register check and a few load immediates in the asm generated from a simple

first_sample = current-array_size

line. However it looks to me like going through the lss file and changing things after every compile then compiling the asm seems a pain. Any simple, and efficient, way of doing the above?

Edward

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> if ((current-array_size)<0) first_sample=0;
> else first_sample = current-array_size;

Why not just:

if (current < array_size) first_sample=0;
else first_sample = current-array_size;

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.