Re: assembly functions ans c++ classes
- From: asetofsymbols@xxxxxxxxx
- Date: 29 Jun 2005 09:56:47 -0700
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
..........
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()
......
// unsigned numbers
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:
unum 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
#include "number.h"
.....
extern "C"
{num* f0(num*,...,num*);
...
num* fn(num*,...,num*);
}
.....
static fnum zz[20];
// 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].num.n, &b.n, &a.n);
/* dif_() is the assembly function*/
else {zz[j].num.n.len=1; zz[j].num.n.n[0]=0;}
return zz[j].num;
}
...
// this file is compiled with
// gcc32 number_lib assembly_file.obj memory_functions.obj
// end file number_lib.cpp
-------------------
// file.cpp that use number_lib.cpp functions
#include "number.h"
....
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_functions.obj
// end of file.cpp
What do you say?
How do you see the subjet?
Are classes useful for definiton of big numbers? Where c++ classes are
usefull?
Why not?
.
- References:
- assembly functions ans c++ classes
- From: asetofsymbols
- Re: assembly functions ans c++ classes
- From: asetofsymbols
- assembly functions ans c++ classes
- Prev by Date: Re: Click...
- Next by Date: Re: Blueflops ate my X
- Previous by thread: Re: assembly functions ans c++ classes
- Next by thread: Re: assembly functions ans c++ classes
- Index(es):
Relevant Pages
|