Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 31st January 2005, 01:36 PM   (permalink)
Default 89c51 32-bit Math calculation

Hi friends,
please, help me for a math problem, i need to calculate:-

(55299539) / ((a*100 + b)*61375 +c)

where a = 0 to 8
b= 0 to 100
c = 0 to 61375

using 89c51 assembly progrmming. what algorithm should i use?
can anyone please provide me a code?

thank you.
garg29 is offline  
Old 1st February 2005, 06:15 AM   (permalink)
Default

You can get a free 8051 C compiler here: http://sdcc.sourceforge.net/

C will let you just type in the equasion just like you have it. The compiler generates all the assembly to do the 32 bit computations. Just cast your variables into longs.

You should also check that a,b, and c don't all equal 0 at the same time or it will generate an error.

Code:
unsigned char a,b;
unsigned int c;
unsigned long d;
a = something;
b = something_else;
c = a_third_thing;
d = (55299539) / ((((long)a*100 + ((long)b)*61375 +((long)c);
the casts ((long)a) arn't really nessesary but I like to put them in to avoid any confusion.
bmcculla is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 04:27 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker