Re: [beagleboard] Is it a bug? control flow instruction of PRU does not make right comparison with negative number

2017-10-31 Thread Lingwei Zhan
Thank you Henner. Since we can only interpret the subtraction result 
correctly when we know its sign, we always need first compare a and b 
(assuming a and b are positive and we do a-b) to know which is greater 
before we do a subtraction.

lingwei

On Tuesday, October 31, 2017 at 12:33:03 PM UTC-4, Henner Zeller wrote:
>
> On 31 October 2017 at 08:49,   wrote: 
> > Thank you Charles. Is it a known issue only for control flow logic? When 
> I 
> > use MOV command to save a negative number (MOV r1, -1), then save r1 
> into 
> > shared RAM, then into a txt file, I do see -1 is saved into the txt file 
> > correctly. 
>
> This always works but has nothing to do with the PRU. 
>
> You can substract a larger value from an unsigned value, which then 
> gets wrapped around; you can then _interpret_ the bit-pattern as a 
> signed value in two-complement and get the expected negative number. 
> This is what you did in this case. 
> This is just a property of how the two-complement encoding works. 
>
> -h 
>
> > 
> > On Tuesday, October 31, 2017 at 9:13:31 AM UTC-4, Charles Steinkuehler 
> > wrote: 
> >> 
> >> On 10/30/2017 4:53 PM, zlw...@gmail.com wrote: 
> >> > I am trying to use QBLT to compare two numbers and found out when one 
> >> > number is negative, the QBLT logic does not seem make right 
> comparison. 
> >> > In 
> >> > the following code, before QBLT, r3 =1-4 = -3, and r2 = 10, so r3 < 
> r2, 
> >> > then the code should execute MOV r3, -1. However, when I run this 
> macro, 
> >> > r3 
> >> > is set to 1. 
> >> > Anyone notices this issue? Any idea how to fix it? 
> >> 
> >> This is a known issue, the PRU supports *ONLY* unsigned integers. 
> >> 
> >> Write your code properly for unsigned data types and you will not have 
> >> any problems. 
> >> 
> >> -- 
> >> Charles Steinkuehler 
> >> cha...@steinkuehler.net 
> > 
> > -- 
> > For more options, visit http://beagleboard.org/discuss 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "BeagleBoard" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to beagleboard...@googlegroups.com . 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/beagleboard/859b4ea7-a3a6-430d-a715-b5d24ccc6a09%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/a5f31638-a696-4ae6-b326-7eb2559c6fbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [beagleboard] Is it a bug? control flow instruction of PRU does not make right comparison with negative number

2017-10-31 Thread Henner Zeller
On 31 October 2017 at 08:49,   wrote:
> Thank you Charles. Is it a known issue only for control flow logic? When I
> use MOV command to save a negative number (MOV r1, -1), then save r1 into
> shared RAM, then into a txt file, I do see -1 is saved into the txt file
> correctly.

This always works but has nothing to do with the PRU.

You can substract a larger value from an unsigned value, which then
gets wrapped around; you can then _interpret_ the bit-pattern as a
signed value in two-complement and get the expected negative number.
This is what you did in this case.
This is just a property of how the two-complement encoding works.

-h

>
> On Tuesday, October 31, 2017 at 9:13:31 AM UTC-4, Charles Steinkuehler
> wrote:
>>
>> On 10/30/2017 4:53 PM, zlw...@gmail.com wrote:
>> > I am trying to use QBLT to compare two numbers and found out when one
>> > number is negative, the QBLT logic does not seem make right comparison.
>> > In
>> > the following code, before QBLT, r3 =1-4 = -3, and r2 = 10, so r3 < r2,
>> > then the code should execute MOV r3, -1. However, when I run this macro,
>> > r3
>> > is set to 1.
>> > Anyone notices this issue? Any idea how to fix it?
>>
>> This is a known issue, the PRU supports *ONLY* unsigned integers.
>>
>> Write your code properly for unsigned data types and you will not have
>> any problems.
>>
>> --
>> Charles Steinkuehler
>> cha...@steinkuehler.net
>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to beagleboard+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beagleboard/859b4ea7-a3a6-430d-a715-b5d24ccc6a09%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/CAEQqtJzcZLifkoKKz2ney2Q%3DBhj8vOaCoLO--QanUeLGuiUGww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [beagleboard] Is it a bug? control flow instruction of PRU does not make right comparison with negative number

2017-10-31 Thread zlw8844
Thank you Charles. Is it a known issue only for control flow logic? When I 
use MOV command to save a negative number (MOV r1, -1), then save r1 into 
shared RAM, then into a txt file, I do see -1 is saved into the txt file 
correctly.

On Tuesday, October 31, 2017 at 9:13:31 AM UTC-4, Charles Steinkuehler 
wrote:
>
> On 10/30/2017 4:53 PM, zlw...@gmail.com  wrote: 
> > I am trying to use QBLT to compare two numbers and found out when one 
> > number is negative, the QBLT logic does not seem make right comparison. 
> In 
> > the following code, before QBLT, r3 =1-4 = -3, and r2 = 10, so r3 < r2, 
> > then the code should execute MOV r3, -1. However, when I run this macro, 
> r3 
> > is set to 1. 
> > Anyone notices this issue? Any idea how to fix it? 
>
> This is a known issue, the PRU supports *ONLY* unsigned integers. 
>
> Write your code properly for unsigned data types and you will not have 
> any problems. 
>
> -- 
> Charles Steinkuehler 
> cha...@steinkuehler.net  
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/859b4ea7-a3a6-430d-a715-b5d24ccc6a09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [beagleboard] Is it a bug? control flow instruction of PRU does not make right comparison with negative number

2017-10-31 Thread Charles Steinkuehler
On 10/30/2017 4:53 PM, zlw8...@gmail.com wrote:
> I am trying to use QBLT to compare two numbers and found out when one 
> number is negative, the QBLT logic does not seem make right comparison. In 
> the following code, before QBLT, r3 =1-4 = -3, and r2 = 10, so r3 < r2, 
> then the code should execute MOV r3, -1. However, when I run this macro, r3 
> is set to 1.
> Anyone notices this issue? Any idea how to fix it?

This is a known issue, the PRU supports *ONLY* unsigned integers.

Write your code properly for unsigned data types and you will not have
any problems.

-- 
Charles Steinkuehler
char...@steinkuehler.net

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/ecf0f332-a2bc-5119-904b-30d5c336f351%40steinkuehler.net.
For more options, visit https://groups.google.com/d/optout.


[beagleboard] Is it a bug? control flow instruction of PRU does not make right comparison with negative number

2017-10-30 Thread zlw8844
I am trying to use QBLT to compare two numbers and found out when one 
number is negative, the QBLT logic does not seem make right comparison. In 
the following code, before QBLT, r3 =1-4 = -3, and r2 = 10, so r3 < r2, 
then the code should execute MOV r3, -1. However, when I run this macro, r3 
is set to 1.
Anyone notices this issue? Any idea how to fix it?

.macro LOGTEST
MOV r7, 1
MOV r8, 4
SUB r3, r7, r8
MOV r2, 10
QBLT LESS, r2, r3
MOV r3, 10
JMP XXX
LESS:
  MOV r3, -1
XXX:
.endm

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/9d82bb20-36c1-4447-855b-8edb58cf47fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.