how to implement a comparator in assemly language

Hi
Am using assembly language to implement DPSK modem  in tms320c50 now am in the final stage that I have to round the results to 1 or to zero
And that basically is a comparator that gives one if the accumulator value is greater then zero or gives zero if the value of the accumulator is less or equal to zero

Can anybody help me in this final stage  
smart_xAsked:
Who is Participating?
 
dimitryConnect With a Mentor Commented:
BCC L1, AR1 <= #0  ; if condition is TRUE skip next command
B L1 || MOV #1, AR1 ; skip next command and set AR1 = 1
MOV #0, AR1        ; set AR1 = 0

In C it will be:
  if( AR1 <= 0 ) goto X0;
  AR1 = 1;
  goto X1;
X0:
  AR1 = 0;
X1:
 
0
 
dimitryCommented:
This is the code for tms320c55, I hope both TI DSP have same assembler:
  BCC L1, AR1 <= #0
  B L1 || MOV #1, AR1
  MOV #0, AR1
where AR1 is accumulator 1.

Actually you can compile next code and see disassembly:
  int i, c;
  i = (c > 0) ? 1 : 0;
0
 
grg99Commented:
the way this is often done in most assembly languages is to do an arithmetic right shift on n-1 bits, where n is the item size.  This gives you a word of zero for positive values, a word of -1 for negative ones.  Then you can either add one to get 0 and 1 (on a two's complement machine).

On a one's complement machine you'll have to do something a bit more clever.

0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
smart_xAuthor Commented:
hi dimitry
thanx for your help,but can you do me some favor,can you comment on the codes
 BCC L1, AR1 <= #0
 B L1 || MOV #1, AR1
 MOV #0, AR1

smart_187
0
 
y2kswCommented:
In a 1st complement machine you may say

not accu
inc accu

to convert to 2nd complement
0
 
CleanupPingCommented:
smart_x:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
dimitryCommented:
It is very strange accepted answer... :)
0
All Courses

From novice to tech pro — start learning today.