carry bit after max instruction
ersmith
Posts: 6,052
Has the behavior of the carry bit been changed for the max and min instructions? It sure seems that way, unless I'm missing something. I tried this simple program:
On P1 I get as output:
but on P2 I get:
#include <stdio.h> #include <propeller.h> // returns the carry bit after max a,b extern _NATIVE int testmax(int a, int b); __asm__( " .section .kernel \n" " .global _testmax \n" "_testmax \n" " maxs r0,r1 wc \n" " mov r0,#0 \n" " muxc r0,#1 \n" "_testmax_ret \n" " ret \n" ); void runtest(int a, int b) { int c = testmax(a, b); printf("testmax(%d, %d)=%d\n", a, b, c); } void main() { runtest(1, 2); runtest(1, 1); runtest(2, 1); }
On P1 I get as output:
testmax(1, 2)=1 testmax(1, 1)=0 testmax(2, 1)=0
but on P2 I get:
testmax(1, 2)=0 testmax(1, 1)=0 testmax(2, 1)=1
Comments
Thanks for the reply! We were using the old behavior in the PropGCC float code. It's not a big deal to change it (it just means adding a "cmp" instruction) but it did kind of surprise me :-).
I guess there's an argument to be made for either behavior. The P1 one was convenient for some things (carry was set if at the end the output D is different from S) but the P2 way is logical too (carry is set if D had to change). At any rate I'm sure it's too late to make any changes, except to the documentation to point out the difference.
Eric