OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Jun 28, 2017 9:47 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: ___udivdi3
PostPosted: Thu Aug 11, 2005 5:25 pm 
hi all, when ever i compile this line:
Code:
unsigned long long start = 0, end = 0, result;
result = (end - start) / 50000;

djgpp says: undifind reference to `___udivdi3 '
i've found it only happends when i divide???, thx


Top
  
 
 Post subject: Re:___udivdi3
PostPosted: Thu Aug 11, 2005 5:29 pm 
Helper function again... this one for dividing 64-bit integers. What a coincidence that you asked this while I was replying to the other thread (http://www.mega-tokyo.com/forum/index.php?board=1;action=display;threadid=8177).


Top
  
 
 Post subject: Re:___udivdi3
PostPosted: Thu Aug 11, 2005 5:40 pm 
thx, helper funtion makes sence, but how do i fix it???


Top
  
 
 Post subject: Re:___udivdi3
PostPosted: Thu Aug 11, 2005 5:46 pm 
You need to either implement the division manually or not use a 64bit division - you can try explicitly casting the 50000 to "unsigned long"(32bit).


Top
  
 
 Post subject: Re:___udivdi3
PostPosted: Thu Aug 11, 2005 5:55 pm 
implement the division manually! thats what I want to do, but how?, i gess i could make a function "div32()" but how to make the function?
Code:
long long div32(long long first, long long second)
{
    int dlow, dhigh, ret;
    dlow = (long)first / (long)second;
    dhigh = (long)first >> 32 / (long)second >> 32;
    ret = ???;
    return ret;
}

am i even close???


Top
  
 
 Post subject: Re:___udivdi3
PostPosted: Thu Aug 11, 2005 5:59 pm 
Run, using a calculator, a few test cases and watch them (fail). Then pick up a pencil and some paper and make it work right, with a little ingenuity.

You will need to give the routine the name DJGPP expects it to have.


Top
  
 
 Post subject: Re:___udivdi3
PostPosted: Fri Aug 12, 2005 1:17 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5959
Location: In a galaxy, far, far away
some hints :
- you may have two 64 bits quantities, but their difference is always 32 bits (e.g. that could be the case if your computing something out of RDTSC, for instance). In that case, just cast the difference to an (unsigned long) and you'll be fine.
- you may have a divisor that is 2^n * m in which case you can shift by n before you actually divide by m

otherwise try to put it as (m*4GB + n) / D == (m/D) * 4GB + (n/D), which should ease further transformations (beware, this is true only if you're operating on real numbers)

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:___udivdi3
PostPosted: Fri Aug 12, 2005 5:19 am 
Offline
Member
Member

Joined: Wed Oct 18, 2006 5:49 am
Posts: 200
AR wrote:
You need to either implement the division manually or not use a 64bit division - you can try explicitly casting the 50000 to "unsigned long"(32bit).


You can also link against libgcc.a, which should contain that function. For DJGPP I think it's in <DJGPP DIR>\lib\gcc\djgpp\<gcc version>\libgcc.a. Something like that anyway. Put that as the last file in the link command, and you won't need to write your own ___udivdi3.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 12, 2008 10:30 pm 
Offline

Joined: Thu Nov 29, 2007 9:56 pm
Posts: 6
Location: Perth, Western Australia
the way i have done it (in a shell script) is to go

Code:
LIBGCC_FILENAME=$(gcc --print-libgcc-file-name)

...build c objects etc...

ld -nostdlib -g -T link.ld -o kernel.o <other object files> $LIBGCC_FILENAME
(note link.ld is your link script)


libgcc contains all the long long math you should need.
replace gcc with your cross-compiler gcc if you have one.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 13, 2008 11:03 am 
Offline
Member
Member
User avatar

Joined: Tue Jul 10, 2007 5:27 am
Posts: 2935
Location: York, United Kingdom
Why bump a three year old thread??

_________________
Horizon - a framework and language for SAS-OS development
Project 'Pedigree'
Practical x86 OSDev tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 13, 2008 11:12 pm 
Offline

Joined: Thu Nov 29, 2007 9:56 pm
Posts: 6
Location: Perth, Western Australia
because it became relevant to me 3 days ago,


Top
 Profile  
 
 Post subject: Re: ___udivdi3
PostPosted: Sat Jul 16, 2011 12:10 am 
Offline

Joined: Sat Jul 16, 2011 12:06 am
Posts: 1
GLneo wrote:
hi all, when ever i compile this line:
Code:
unsigned long long start = 0, end = 0, result;
result = (end - start) / 50000;

djgpp says: undifind reference to `___udivdi3 '
i've found it only happends when i divide???, thx


No compitable for 64bit )
spam removed


Last edited by thepowersgang on Tue Feb 21, 2017 11:01 pm, edited 4 times in total.
spamspamspamspam


Top
 Profile  
 
 Post subject: Re: ___udivdi3
PostPosted: Sat Jul 16, 2011 12:16 am 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 7:42 pm
Posts: 1391
Location: Unknown. Momentum is pretty certain, however.
Next level old thread bump maneuver.

Actually (hahaha)...
JamesM...in this very thread... wrote:
Why bump a three year old thread??


-JL

_________________
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io


Top
 Profile  
 
 Post subject: Re: ___udivdi3
PostPosted: Sat Jul 16, 2011 12:58 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1030
Location: Tartu, Estonia
Guess what will happen 3 years from now...

_________________
Programmers' Hardware Database // SF user: xenos1984; OS project: XeNOS


Top
 Profile  
 
 Post subject: Re: ___udivdi3
PostPosted: Tue Feb 21, 2017 5:33 pm 
Offline
Member
Member
User avatar

Joined: Mon Feb 22, 2016 4:40 am
Posts: 32
Location: United Kingdom
XenOS wrote:
Guess what will happen 3 years from now...


You were wrong. 6 years. Boo. I'm searching for a solution to this problem too.

_________________
Current developing Tupai, a monolithic x86 operating system
http://zesterer.homenet.org/projects.shtml


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], ~ and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group