DavidEQ 4 Posted August 16, 2011 Share Posted August 16, 2011 There a good way to accumulate a 32 bit unsigned int with another 32 bit unsigned int? Looking at the instruction seet I found ADD(. and ADDC(. Not real sure if that means it only works on bytes or if ADD works for words and ADD(. is for bytes etc. Also not sure how to take a c launge int add pass it to assembler.... Maybe a pointer to the right doc would help. I am sure the following won't work but I think you may be able to tell what I want to do from it. unsigned int phase_acc_high; unsigned int phase_acc_low; unsigned int phase_inc_high; unsigned int phase_inc_low; ADD phase_inc_low, phase_acc_low;// ADD(. src,dst src + dst ? dst ADDC phase_inc_high, phase_acc_high;// ADDC(. src,dst src + dst +c ? dst Quote Link to post Share on other sites
oPossum 1,083 Posted August 16, 2011 Share Posted August 16, 2011 In C unsigned long phase_inc; unsigned long phase_acc; phase_acc += phase_inc; In assembly .bss phase_inc, 4 .bss phase_acc, 4 add &phase_inc, &phase_acc addc &phase_inc + 2, &phase_acc + 2 Variables are passed in R12 to R15, and then the stack. slau132d section 6.4.1 page 100, section 6.5 page 102 DavidEQ 1 Quote Link to post Share on other sites
DavidEQ 4 Posted August 16, 2011 Author Share Posted August 16, 2011 Thanks, for some reason I thought if its a 16 bit chip the C compiler would choke on long ints. After posted this I looked over the supported data types last night for a bit. Is there an proper way to more or less directly use the 2^32 to 2^17 word of the long as a regular unsiged word without doing a divide? Would this work or will it use the lower magnitue word? unsinged long abc; unsinged int *xyz =&abc; dosomething(xyz); Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.