This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

_remi function usage (RTS asm funciton)



Hi,

I would like to optimize our C code using modulo(%).
My question is whether I can use _remi (RTS built-in asm function) for this purpose.
I'm asking this because UG says that this function is not intended to be called directly from user application code.
======
http://www.ti.com/lit/ug/spru187o/spru187o.pdf
7.7 Run-Time-Support Arithmetic Routines
These routines follow the standard C/C++ calling sequence. The compiler automatically adds these routines when appropriate; they are not intended to be called directly by your programs.
======

On the other hand, remi.asm (rstsrc.zip came from CGT) mentions that he will use the following core registers during his operation:

; Regs used:
; A1 = neg_num, zero_quo
; A2 = mag_num, neg_quo
; A4 = arg1: numerator, abs_num, retval: remainder
; A5 = copy numerator
; A6 = copy neg_num
; B0 = subc loop counter
; B1 = loop counter, neg_den, mod
; B2 = mag_den, neg_loopcount, modulo_shift
; B3 = return address
; B4 = arg2: denominator, abs_den
;
; Regs killed:
; A1, A2, A4, A5, A6, B0, B1, B2, B4
;
; Regs used but not killed:
; B3

So, if the above registers are taken care (push/pop operation to/from stack) at caller side, I believe it is okay to use this function.
And I guess TI's C compiler (for c674x) can take care it automatically under its compile rule for "calling assembly routine from C code".
How do you think ?
If you have other solutions for % optimization, it will be helpful for us.

Best Regards,
Kawada

  • Naoki kawada said:
    I would like to optimize our C code using modulo(%).
    My question is whether I can use _remi (RTS built-in asm function) for this purpose.

    If you are using C code, just use the modulo operator %.  The compiler will automatically change this to a call to _remi.  You should not attempt to call _remi directly in C code.

    If you are using assembly code, you are certainly free to call _remi, as long as you obey the C calling convention, as modified by the documentation you quote.  That is, _remi is guaranteed not to kill any registers that aren't explicitly documented as killed.