Re: assembly functions ans c++ classes



On 28 Jun 2005 22:04:54 -0700, asetofsymbols@xxxxxxxxx wrote:
>
now i think this

I have some assembly function
num* f0(num*,...,num*);
....
num* fn(num*,...,num*);
where I will say num is this struct
typedef struct{unsigned len; unsigned* n}num;

I have thought and decided for c++ classes
---------------------------------------------
//file number.h
// this is the file need to include if someone
// use the big number library

// for unsigned number:

typedef struct{unsigned len; unsigned* n}num;
// but it is not helpfull that num is accessed from extern
// but it is need in the definition of class unum

// here some usefull function like getline()

class unum{
public:
fucntions and operators that use f0, f1... fn
example
friend unum& operator-(const unum& a, const unum& b);
...
private:
num n; // number
unsigned lm; // memory
}

//the class for signed big numbers
class snum{
public:
fucntions and operators that use f0, f1... fn
example
friend snum& operator-(const snum& a, const snum& b);
...
private:
num sn; // number
int sign;
}

//the class for big float

class fnum{
public:
fucntions and operators that use f0, f1... fn
example
friend fnum& operator-(const fnum& a, const fnum& b);
...
private:
snum fn;
unsigned fdigit;
}
// end of file number.h
---------------
// file number_lib.cpp

extern "C"
{num* f0(num*,...,num*);
...
num* fn(num*,...,num*);
}

// here the definitons of operator and function of number.h

unum& operator-(const unum& a, const unum& b)
{unsigned j=indx();
if(minor(&b.n, &a.n)>=0)
dif_(&zz[j].n, &b.n, &a.n); /* dif_() is the assembly function*/
else {zz[j].n.len=1; zz[j].n.n[0]=0;}
return zz[j];
}
...
// this file is compiled with
// gcc32 number_lib assembly_file.obj memory_function.obj
// end file number_lib.cpp
-------------------
// file.cpp that use number_lib.cpp functios

int main(void)
{unum a("123333333331345444444"), b(12444.55),
c(45678), d("454541115");
cout << " a==" << a;
c=(a*b+c)%d;
cout << " c==" << c;
return 1;
}

// this file is compiled with
// gcc32 file number_lib.obj assembly_file.obj memory_function.obj
// end of file.cpp

What do you say?

.



Relevant Pages