Set a registers bit according to another registers bit PRU

70 views
Skip to first unread message

Michi Jäger

unread,
May 21, 2016, 4:56:57 AM5/21/16
to BeagleBoard

Hello!

I want to set a register's bit to the value of another registers bit in PRU.
I have the following code (which is working) but i want to know if there is a more beatiful option to do this:

QBBS    SENDHIGH, r0.t0
QBBC    SENDLOW, r0.t0

SENDHIGH:
    SET        r29.t1

SENDLOW:
    CLR        r29.t1

Greg

unread,
May 21, 2016, 2:08:47 PM5/21/16
to BeagleBoard
I am just now starting to read assembly, so this may not be correct:

QBBS    SENDHIGH, r0.t0
  CLR        r29.t1

SENDHIGH:
    SET        r29.t1

That removes 2 lines.  I think.
In pseudo C code:

if r0.t0 = 1
   r29.t1 =1;
else
  r29.t1 = 0;

Regards,
Greg

Message has been deleted
Message has been deleted
Message has been deleted

TJF

unread,
May 22, 2016, 12:13:10 PM5/22/16
to BeagleBoard
None of the codes will work, since the last executed instruction is always
CLR        r29.t1
in the first code or
SET        r29.t1
in the second code. This will always clear or set the bit, independend from r0.t0.

Either use
  QBBS  SENDHIGH, r0.t0
  CLR   r29
.t1
  JMP   Finish

SENDHIGH
:
  SET   r29
.t1

Finish:

But, does this simple solution don't work?
MOV r29.t1, r0.t0

Charles Steinkuehler

unread,
May 22, 2016, 1:34:43 PM5/22/16
to beagl...@googlegroups.com
On 5/22/2016 11:13 AM, TJF wrote:
> But, does this simple solution don't work?
> |
> MOV r29.t1,r0.t0

The smallest value the MOV instruction will work with is a byte.

See "Syntax Terms and Definitions", section 5.3.2.5.6 of the PRU
Reference Guide (SPRUHF8). The MOV instruction works with any
register field from 8 to 32 bits, but not with single bits.

--
Charles Steinkuehler
cha...@steinkuehler.net

Michi Jäger

unread,
May 23, 2016, 12:38:42 PM5/23/16
to BeagleBoard
Yes exactly that is the problem. What should work is the OR operator, combining the two registers:

r29:  0010 0000
r0:    0000 0001

When performing a LSL on r0:

r0:    0000 0010

and combining the two with the OR operation r29 becomes:

r29:  0010 0010

but anyways this takes too long for my usecase.
I might need to play around with what I've got in the code already, because it is working, but i wanted a "nicer" solution.
Reply all
Reply to author
Forward
0 new messages