Solved

# how to implement a comparator in assemly language

Posted on 2003-03-19
Medium Priority
399 Views
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
0
Question by:smart_x
[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

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;
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.

0

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

smart_187
0

LVL 3

Expert Comment

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

not accu
inc accu

to convert to 2nd complement
0

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;
X0:
AR1 = 0;
X1:

0

Expert Comment

ID: 10138816
smart_x:
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

LVL 11

Expert Comment

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

## Featured Post

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