Mail Archives: djgpp/1998/09/09/11:42:52
On Wed, 9 Sep 1998, Tal Lavi wrote:
> short_div_t short_div(unsigned short numberator,
> unsigned short denomonator)
> {
> short_div_t short_div;
> __asm__ __volatile__("
> divw %%bx"
> :"=a"(short_div.quot),"=d"(short_div.rem)
> :"a"(numberator),"d"((unsigned short)0),"b"(denomonator)
> :"ax","bx","dx"
> );
> return(short_div);
> }
Assuming this works (sorry, don't have enough time to have a good look),
here are some comments:
1) Why do you use word-size arguments and DIVW opcode? Going to
shorts will slow down your program considerably, since switching to
16-bit operands in an otherwise 32-bit program requires a size-override
prefix which causes the code to run at half the speed. Maybe the fact
that you use shorts in your program is the real reason behind your
slow-downs?
I suggest to work with int's, not short's.
2) The above code doesn't handle the case where the second
argument is negative. I don't know whether your program needs that.
> Can I #define the inline asm command, instead of calling a real
> function?
Just define it with the __inline__ qualifier, and make sure its
definition is *before* it is called in the program, and GCC will inline
it for you thus avoiding the overhead of the call.
> Bear in mind that I'm using _farns* functions on a double page LFB,
> it should be FASSST!
Did you try to use _farnspokel instead of _farnspokew?
> But when I try to compile the file in order to profile it:
>
> gcc -o ray.exe ray.c vesa64.c -O2 -ffast-math -pg
>
> The running of the .exe is hanging my system!
This is explained in the FAQ (section 13.2): stock v2.01 library has a
bug in one of its functions that is linked into your program when you use
-pg. Get a patched library from the URL below and relink, and the
problem should go away:
WWW: http://www.cartsys.com/eldredge/djgpp-patches.html
ftp: ftp://www-leedr.arme.cornell.edu/pub/djgpp-patches/). Be sure to
read the file `ftp.message.txt' when using the FTP server above. The
file `README' explains how the patched library can be downloaded and used.
> create a gmon.out file.
> here it is, does it make sense?!?
No, it doesn't. The FAQ explains that gmon.out is written by a function
registered via `atexit'. If you abort the profiled program with Ctrl-C,
the normal exit code is bypassed, and gmon.out info is not written.
- Raw text -