[comp.sys.handhelds] SAD compilation problems....

kamidon@zip.eecs.umich.edu (Keith Amidon) (12/23/90)

I have  recently aquired a copy of the source to the SAD disassembler.
Since I don't own a C compiler for my Amiga, I also ftp'd a shareware
compiler called DICE to use to compile it.  I have set everything up 
and dice appears to work extremely well (for those Amiga users out there,
it works so well I am seriously considering sending in the fee and
keeping it around)  Anyway, the one problem I have run into is that
SAD expects there to be a library function called qsort, which doesn't
seem to exist in DICE's libraries.  The question of the day is....

    Can anyone tell me what exactly qsort does, and if
    possible, where I can find sources for a routine doing the
    same thing which I could link into the SAD programs?

I would appreciate any information you can give me.

              Thanks.....    Keith Amidon

kamidon@zip.eecs.umich.edu 
-- 

bson@rice-chex.ai.mit.edu (Jan Brittenson) (12/24/90)

In article <1990Dec22.180316.647@zip.eecs.umich.edu> 
   kamidon@zip.eecs.umich.edu (Keith Amidon) writes:

   When porting SAD, make sure that integers are 32 bits or more
(shouldn't pose any problems on 68k machines) and that all data types
and pointers (except double) are passed on the stack as 32-bit
quantities.


 > ... the one problem I have run into is that SAD expects there to be a
 > library function called qsort, which doesn't seem to exist in DICE's
 > libraries.

From the SunOS man(1) page:

   SYNOPSIS
        qsort(base, nel, width, compar)
        char *base;
        int (*compar)();
   
   DESCRIPTION
        qsort() is an implementation of the quicker-sort  algorithm.
        It sorts a table of data in place.
   
        base points to the element at the base of the table.  nel is
        the  number of elements in the table.  width is the size, in
        bytes, of each element in the table.  compar is the name  of
        the  comparison function, which is called with two arguments
        that point to the elements being compared.  As the  function
        must  return an integer less than, equal to, or greater than
        zero, so must the first argument to be  considered  be  less
        than, equal to, or greater than the second.


   Note that the description is confusing; compar is not the name
(implying name in ascii) of the comparison function, but rather a
pointer to it, i.e. (int (*)()) as defined in the synopsis above.

I mention this because I've seen attempts to do things like:

  /* WRONG */  qsort(..., "my_cmp");  /* WRONG */

(Usually by students, but worth mentioning nevertheless.)


 > [Where can I] find sources for a routine doing the same thing which I
 > could link into the SAD programs?

   Check with project GNU's C Standard Library at FTP address
prep.ai.mit.edu. qsort should be fairly self-contained and not require
much else from the library - send me mail if you need help with
this.

						-- Jan Brittenson
						   bson@ai.mit.edu