View Single Post
Old 21st November 2012, 18:30   #17  |  Link
martin53
Registered User
 
Join Date: Mar 2007
Posts: 407
Quote:
Originally Posted by davidhorman View Post
Hi Martin,

I'm not sure what you mean about dup
- You are right: MaskTools also use RPN, and I feel it would be a good idea to use similar operand sets. I only used yv12lut so far. There is no min operator. To subtract a value, but avoid negative results, I write "x 128 - 0 < 0 x 128 - ?", or in human speech, "subtract 128 from x, and if the result is below zero, take zero, else take x minus 128". X-128 must be computed twice, and if I needed to limit a very complicated expression, I have no confidence that I could manage that (bug finding is not easy with RPN). I thought that with dup, an intermediate result could be stored and re-used more easily. But in fact it would be useless because the copy is needed only later and cannot easily handled on the RPN stack.

A different strategy would be needed. A limited set of 'variables'-operands, like 's0' stores top of stack to 'v0' and leaves it also on stack, 'r0' recalls 'v0' to top of stack would help - and stay within the syntax.

As a side thought: To facilitate bug finding, the function could throw an error if the expression does not end with 1 entry on the stack, and dump the stack. What do you think about this?
martin53 is offline   Reply With Quote