//******************************************************************************* // Kalimba / Elvis DSP Assembler Macros // for CSR BC3 or BC5 DSP chipsets // by: Regulus Berdin (c) 2007 // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following // conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL REGULUS BERDIN BE LIABLE FOR // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. .ifndef _MACROS_ASM_ .define _MACROS_ASM_ //---------------------------------------------------------- .define BR_FLAG 0x0040 .define NOT_BR_FLAG 0xFFBF //---------------------------------------------------------- .define COMPARE(p1,p2) \ r0 = p1; \ NULL = r0 - p2 .define JUMP_IF(pflag, plocation) if pflag jump plocation .define JUMP_IF_COMP(pflag, p1, p2, plocation) \ COMPARE(p1,p2); \ JUMP_IF(pflag, plocation) .define IF_GT_JUMP_ELSE(p1, p2, plocation) JUMP_IF_COMP(LE, p1, p2, plocation) .define IF_GE_JUMP_ELSE(p1, p2, plocation) JUMP_IF_COMP(LT, p1, p2, plocation) .define IF_LT_JUMP_ELSE(p1, p2, plocation) JUMP_IF_COMP(GE, p1, p2, plocation) .define IF_LE_JUMP_ELSE(p1, p2, plocation) JUMP_IF_COMP(GT, p1, p2, plocation) .define IF_EQ_JUMP_ELSE(p1, p2, plocation) JUMP_IF_COMP(NE, p1, p2, plocation) .define IF_NE_JUMP_ELSE(p1, p2, plocation) JUMP_IF_COMP(EQ, p1, p2, plocation) //---------------------------------------------------------- .define SET_MEM(pmem, pconst) \ r0 = pconst; \ M[pmem] = r0 .define LOOP(pconst, plocation) \ r10 = pconst; \ do plocation .define ADD_MEM(pmem, pconst) \ r0 = M[pmem]; \ r0 = r0 + pconst; \ M[pmem] = r0 .define SUB_MEM(pmem, pconst) \ r0 = M[pmem]; \ r0 = r0 - pconst; \ M[pmem] = r0 .define INCR(pmem) \ r0 = M[pmem]; \ r0 = r0 + 1; \ M[pmem] = r0 .define DECR(pmem) \ r0 = M[pmem]; \ r0 = r0 - 1; \ M[pmem] = r0 .define ADD(rr, p1, p2) \ rr = p1; \ rr = rr + p2 .define SUB(rr, p1, p2) \ rr = p1; \ rr = rr - p2 //---------------------------------------------------------- .define INCR_READ_ADDRESS(addr, value) \ r0 = &addr; \ call $cbuffer.get_read_address_and_size; \ I0 = r0; \ M0 = value; \ r0 = M[I0,M0]; \ r0 = &addr; \ r1 = I0; \ call $cbuffer.set_read_address .define INCR_WRITE_ADDRESS(addr, value) \ r0 = &addr; \ call $cbuffer.get_write_address_and_size; \ I0 = r0; \ M0 = value; \ r0 = M[I0,M0]; \ r0 = &addr; \ r1 = I0; \ call $cbuffer.set_write_address .endif