GDA_Conv Library

General discussion on mikroC.
Post Reply
Author
Message
gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

GDA_Conv Library

#1 Post by gambrose » 18 May 2005 20:14

Here is the conversion library what I wrote.

http://gambrose.esmartdesign.com/GDA_Conv%20Library.zip

It’s not finished but I hope it is useful to people who use P16 PICs as it’s faster than the standard one.

I hope to add support for P18 and other functions later.


Any comments or suggestions gratefully received.
If you find use for it then I would be happy to here off you
Graham Ambrose

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#2 Post by gambrose » 01 Jun 2005 19:20

I have managed to get it to compile for P18 although I have not tested it yet.

I also have added Byte2Str which is the same as ByteToStr but runs in less than 90 cycles rather than over 1,500 cycles not too shabby.
Graham Ambrose

anton
Posts: 807
Joined: 23 Sep 2004 09:16
Location: South-Africa
Contact:

#3 Post by anton » 01 Jun 2005 19:30

Thank you gambrose

I've downloaded the zip file and will test tonight :D
Another proud user of LV 24-33A Development System and mikroPascal PRO for dsPIC :)
PortA not working? Add CMCON := 7; PortD not working? Add ADCON1 := 6;
To paste code on the forum, please use the [b] Code [/b] button !! ;)

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#4 Post by LGR » 01 Jun 2005 19:37

Anton - since you're brave enough to test these C routines, I would appreciete it if you let me (us) know what this adds to Pascal, or if this is even usable with Pascal (the .mcl files are supposed to be portable). :D
If you know what you're doing, you're not learning anything.

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#5 Post by gambrose » 01 Jun 2005 19:49

What it should do is add number to string routines that are faster than the current built in ones
as well as number to BCD that are faster and actual convert to BCD.
most of the routines are also smaller in size and don't make out side calls saving call stack space.
they also return a pointer to the text so that whey can be used inside other routines. e.g.

Code: Select all

print_string(byte2String(34)); 
they are a work in progress and hopefully most if not all the asm can be changed for c code as the compiler matures.

I would have included a .mcl for you to test but mE have made it too hard to install them by hand so it isn't really worth it.
Graham Ambrose

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#6 Post by LGR » 01 Jun 2005 19:57

gambrose wrote:I would have included a .mcl for you to test but mE have made it too hard to install them by hand so it isn't really worth it.
This is an important thing for them to be working on. One of the real attractions to mE compilers is that we can all have our favorite languages, and still make contributions to (and withdrawls from) a free software bank. It is obvious to be that while we can only have open source in the original language, we should be able to bundle the libraries for use in any and all languages. There is tremendous potential here. We need a straightforward means to create binary libraries. 8)
If you know what you're doing, you're not learning anything.

anton
Posts: 807
Joined: 23 Sep 2004 09:16
Location: South-Africa
Contact:

#7 Post by anton » 01 Jun 2005 19:59

LGR
Anton - since you're brave enough to test these C routines, I would appreciete it if you let me (us) know what this adds to Pascal, or if this is even usable with Pascal (the .mcl files are supposed to be portable).
Ok, i'll do that. :wink:

gambrose

You have the following code

Code: Select all

        Long2String(123456789); // 1,448 cycles
and the prototype for this function is

Code: Select all

char * Long2String(unsigned long num);
now my question is a long can be more that one characters and you can only return one :?:

I can be wrong. I use Pascal :twisted:
Another proud user of LV 24-33A Development System and mikroPascal PRO for dsPIC :)
PortA not working? Add CMCON := 7; PortD not working? Add ADCON1 := 6;
To paste code on the forum, please use the [b] Code [/b] button !! ;)

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#8 Post by gambrose » 01 Jun 2005 20:21

It returns a pointer to a char (or in this case an array of chars) i.e. a string.

I don't know what you have in Pascal for strings?
Graham Ambrose

anton
Posts: 807
Joined: 23 Sep 2004 09:16
Location: South-Africa
Contact:

#9 Post by anton » 01 Jun 2005 20:25

Ok. Sorry, I've over looked the *. Now i understand. :oops:
Another proud user of LV 24-33A Development System and mikroPascal PRO for dsPIC :)
PortA not working? Add CMCON := 7; PortD not working? Add ADCON1 := 6;
To paste code on the forum, please use the [b] Code [/b] button !! ;)

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#10 Post by zristic » 01 Jun 2005 20:59

We will test these libs too. If they are OK, we will provide them as additional compilers' libs (with sources).

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#11 Post by gambrose » 01 Jun 2005 21:12

Well like i said it's not finished and i haven't had much experience of P18 so i am not sure of how these routines will work with respect to banking etc.
Graham Ambrose

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#12 Post by gambrose » 02 Jun 2005 18:05

Have added

Code: Select all

char * Word2Str(unsigned number, char * output);
and optimised Byte2Str for P18

Word2Str works but there seems to be a problem with large numbers. it will work fine in a test project with just the one function but when i copy it into the main library file it goes a bit wobbly :(
Graham Ambrose

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#13 Post by zristic » 02 Jun 2005 21:34

Code: Select all

Word2Str works but there seems to be a problem with large numbers
:P
That's why it is smaller and faster
:P

gambrose
Posts: 369
Joined: 28 Sep 2004 17:34
Location: uk

#14 Post by gambrose » 03 Jun 2005 09:50

Don't be so mean :cry:

I found the problem the code was not clearing the array properly all the time as i had copy and pasted rotate left instructions instead of clear instructions :oops:

It's faster because it uses a different algorithm that i have tried to optimise for speed buy using asm.
Graham Ambrose

Post Reply

Return to “mikroC General”