Jump to content
43oh

32 bit simple accumulate


Recommended Posts

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(.B) and ADDC(.B)

 

Not real sure if that means it only works on bytes or if ADD works for words and ADD(.B) 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(.B) src,dst src + dst ? dst

ADDC phase_inc_high, phase_acc_high;// ADDC(.B) src,dst src + dst +c ? dst

Link to post
Share on other sites

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

Link to post
Share on other sites

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...