how to implement a comparator in assemly language

Posted on 2003-03-19
Medium Priority
Last Modified: 2008-03-04
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  
Question by:smart_x
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Expert Comment

ID: 8171304
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;
LVL 22

Expert Comment

ID: 8171456
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.


Author Comment

ID: 8172536
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.


Expert Comment

ID: 8175387
In a 1st complement machine you may say

not accu
inc accu

to convert to 2nd complement
LVL 11

Accepted Solution

dimitry earned 480 total points
ID: 8177250
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;
  AR1 = 0;

Expert Comment

ID: 10138816
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 
Post your closing recommendations!  No comment means you don't care.
LVL 11

Expert Comment

ID: 10257385
It is very strange accepted answer... :)

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question