Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
24 May, 2013, 09:55:23 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 ... 7 8 [9] 10 11 ... 13   Go Down
  Print  
Author Topic: Post your Nspire routines here! -  (Read 15453 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 19 May, 2013, 16:59:33
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #120 on: 05 September, 2010, 03:00:03 »
0

Looks nice bwang!

Thanks for all of your hard work! Smiley
Logged


bwang
LV7 Elite (Next: 700)
*******
Offline Offline

Last Login: 11 August, 2012, 12:59:06
Date Registered: 20 June, 2009, 01:42:58
Posts: 632

Topic starter
Total Post Ratings: +19

View Profile
« Reply #121 on: 05 September, 2010, 05:45:48 »
0

Thanks! Have you tested it? If it works with your projects, I think I'll replace the skeleton in the OP with it.
Logged
apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 19 May, 2013, 16:59:33
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #122 on: 06 September, 2010, 00:11:15 »
0

Yes, I have tested this and it seems to work fine!

The only complaint I have is that the compiled program, on the emulator, was 33K (this was the main.c with no actual code in it included in the library, not one of my programs).  I assume this could be caused by my GCC/Makefile I am using (it is probably including functions not actually used by the program, say atoi(, for example).  I am not good at all with coding Makefiles (I used the one that came with Ndless--not the one included with the library, which gave me an error message), so I really don't know if this is fixable.  I do like how all of the functions are in one place, though!  If nothing, I could just pick and choose the headers I want and just not build the .a file. Thanks again for your hard work on this Cheesy!
Logged


bwang
LV7 Elite (Next: 700)
*******
Offline Offline

Last Login: 11 August, 2012, 12:59:06
Date Registered: 20 June, 2009, 01:42:58
Posts: 632

Topic starter
Total Post Ratings: +19

View Profile
« Reply #123 on: 06 September, 2010, 03:37:43 »
0

Hmm...perhaps I should break the libraries into separate files, so the user does not need to link everything into his program.
Then again, 33K is not very large considering the fact that the Nspire has 32 MB of flash. Even accounting for the OS, it's still over 20 MB.
Logged
apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 19 May, 2013, 16:59:33
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #124 on: 06 September, 2010, 03:42:37 »
0

33K is not very large in itself, but that is just what you are starting with.  I know that currently Trapped is 20K.  If I added these files in, that might double the size.  An extra, say 15-20K on every Ndless program you have on your calc can add up quickly.  There has to be some way to have it not include the unused functions.  I am almost sure TIGCC/GCC4TI dose it.  You can include one file:


1
2
#include <tigcclib.h>

This includes all headers for use, but it does not start the program at the size of all of the headers plus your code, only your code and the functions used by it.  I am not sure how it is done, but one of the maintainers of GCC4TI might know.
« Last Edit: 06 September, 2010, 03:43:22 by apcalc » Logged


ExtendeD
Coder Of Tomorrow
LV8 Addict (Next: 1000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:41:25
Date Registered: 02 January, 2010, 13:03:41
Location: France
Posts: 766

Total Post Ratings: +151

View Profile
« Reply #125 on: 06 September, 2010, 22:48:26 »
0

I haven't a clue what syscalls.c is. It came with Ndless.

syscalls.c contains OS stubs requires by "newlib" (the implementation of stdlib integrated with YAGARTO).
The stdlib is not really required in our case, because most of the functions can be found in the TI-Nspire OS, you just need to define them in Ndless headers.
And it appears that newlib is built without -fpic in YAGARTO (pc-relative instructions), so the stdlib functions may crash.
The stdlib should only be enabled if the program uses floating-point arithmetic, similarly to the Ndless's particles demo.

Most programs should be built with the -nostdlib option for nspire-ld.

There has to be some way to have it not include the unused functions.  I am almost sure TIGCC/GCC4TI dose it.

Headers do not influence program size, the libraries does. The .a file should contain separate .o files (as it does). The granularity for inclusion is a .o file. So your problem is quite strange.

Could you try to build with the flag -nostdlib for nspire-ld? Could you check that the .tns doesn't contain series of zeros?
Could you try to run a "arm-none-eabi-objdump.exe -D <your_program.elf>" which disassemble the program, and see which symbols appear?
Logged

ndlessly - Progress and insights on Ndless
Ndless / Hackspire - Third-party TI-Nspire development
apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 19 May, 2013, 16:59:33
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #126 on: 06 September, 2010, 23:13:02 »
0

This is really strange, but I went back to compile the same exact file, and it compiled to 3K!

Even better, when I added the flag -nostdlib to the Makefile, the size went down to 1K (although this would only work for the blank file included with the skeleton; when I tried it on Trapped, it complained of undefined references to memset and memcpy)!!

I can't explain why it went down from 33K, as I made no edits at all, but at least it is working now!!
Logged


DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 08:21:29
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50232


Total Post Ratings: +2615

View Profile WWW
« Reply #127 on: 07 September, 2010, 09:30:09 »
0

Did you change some files used for compiling? That seems a bit strange. I hope this doesn't mean data loss... x.x
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
ExtendeD
Coder Of Tomorrow
LV8 Addict (Next: 1000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:41:25
Date Registered: 02 January, 2010, 13:03:41
Location: France
Posts: 766

Total Post Ratings: +151

View Profile
« Reply #128 on: 08 September, 2010, 21:22:50 »
0

when I tried it on Trapped, it complained of undefined references to memset and memcpy)!!
This is odd: this means you are using stdlib's memset/memcpy instead of the TI-Nspire OS's.
Does the .c which memsets/memcopies includes <os.h>?
Logged

ndlessly - Progress and insights on Ndless
Ndless / Hackspire - Third-party TI-Nspire development
apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 19 May, 2013, 16:59:33
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #129 on: 08 September, 2010, 21:36:55 »
0

Yes, the .c file includeds <os.h>

Even stranger, I went to test this by renaming all instances of memset and memcpy to _memset and _memcpy, respectively, and went into <os.h> and renamed memset and memcpy (the ti-os ones) to _memset and _memcpy, respectively, and it still complained memset and memcpy were undefined, despite the fact that they are not even used by the program at all.

What is confusing me even more is that it is complaining that these two functions are not defiend in a function that does not even use these functions at all.  Here is the error I am getting:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Danny@DANNYCOMPUTER /c/users/danny/documents/ti-nspire/development/trapped
$ make clean;make
nspire-gcc -Os -Wall -W -fpic -fno-merge-constants -D NON_CAS -c main.c
nspire-gcc -Os -Wall -W -fpic -fno-merge-constants -D NON_CAS -c utils.c
nspire-ld main.o utils.o -nostdlib -o Trapped.elf
utils.o: In function `setlevel':
utils.c:(.text+0x28): undefined reference to `memset'
utils.c:(.text+0x1f8): undefined reference to `memset'
utils.o: In function `setladder':
utils.c:(.text+0x504): undefined reference to `memset'
utils.c:(.text+0x540): undefined reference to `memset'
utils.o: In function `drawlevel':
utils.c:(.text+0x8f0): undefined reference to `memcpy'
utils.c:(.text+0x904): undefined reference to `memcpy'
utils.c:(.text+0x918): undefined reference to `memcpy'
utils.c:(.text+0x92c): undefined reference to `memcpy'
utils.c:(.text+0x944): undefined reference to `memcpy'
utils.o:utils.c:(.text+0x95c): more undefined references to `memcpy' follow
collect2: ld returned 1 exit status
make: *** [Trapped.tns] Error 1

Danny@DANNYCOMPUTER /c/users/danny/documents/ti-nspire/development/trapped
$

The function "setlevel" does not call these functions at all; drawlevel only calls them in the form of the sprite function and to clear a buffer.
Logged


Goplat
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: Today at 07:37:57
Date Registered: 08 December, 2009, 13:17:47
Posts: 289

Total Post Ratings: +77

View Profile
« Reply #130 on: 09 September, 2010, 00:17:48 »
0

gcc will sometimes emit calls to memset or memcpy functions if you initialize or assign large structures. Having them as macros won't help. I think we need to have real memset and memcpy functions in the library (even if all they do is call the OS functions).
Logged

Numquam te deseram; numquam te deficiam; numquam circa curram et te desolabo
Numquam te plorare faciam; numquam valedicam; numquam mendacium dicam et te vulnerabo
bwang
LV7 Elite (Next: 700)
*******
Offline Offline

Last Login: 11 August, 2012, 12:59:06
Date Registered: 20 June, 2009, 01:42:58
Posts: 632

Topic starter
Total Post Ratings: +19

View Profile
« Reply #131 on: 09 September, 2010, 03:57:09 »
0

Yes, the .c file includeds <os.h>

Even stranger, I went to test this by renaming all instances of memset and memcpy to _memset and _memcpy, respectively, and went into <os.h> and renamed memset and memcpy (the ti-os ones) to _memset and _memcpy, respectively, and it still complained memset and memcpy were undefined, despite the fact that they are not even used by the program at all.

What is confusing me even more is that it is complaining that these two functions are not defiend in a function that does not even use these functions at all.  Here is the error I am getting:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Danny@DANNYCOMPUTER /c/users/danny/documents/ti-nspire/development/trapped
$ make clean;make
nspire-gcc -Os -Wall -W -fpic -fno-merge-constants -D NON_CAS -c main.c
nspire-gcc -Os -Wall -W -fpic -fno-merge-constants -D NON_CAS -c utils.c
nspire-ld main.o utils.o -nostdlib -o Trapped.elf
utils.o: In function `setlevel':
utils.c:(.text+0x28): undefined reference to `memset'
utils.c:(.text+0x1f8): undefined reference to `memset'
utils.o: In function `setladder':
utils.c:(.text+0x504): undefined reference to `memset'
utils.c:(.text+0x540): undefined reference to `memset'
utils.o: In function `drawlevel':
utils.c:(.text+0x8f0): undefined reference to `memcpy'
utils.c:(.text+0x904): undefined reference to `memcpy'
utils.c:(.text+0x918): undefined reference to `memcpy'
utils.c:(.text+0x92c): undefined reference to `memcpy'
utils.c:(.text+0x944): undefined reference to `memcpy'
utils.o:utils.c:(.text+0x95c): more undefined references to `memcpy' follow
collect2: ld returned 1 exit status
make: *** [Trapped.tns] Error 1

Danny@DANNYCOMPUTER /c/users/danny/documents/ti-nspire/development/trapped
$

The function "setlevel" does not call these functions at all; drawlevel only calls them in the form of the sprite function and to clear a buffer.
Is this only a problem when you use the statically-linked library?
Logged
apcalc
The Game
Coder Of Tomorrow
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: 19 May, 2013, 16:59:33
Date Registered: 20 March, 2010, 16:31:47
Location: 2003 UB313
Posts: 1393


Total Post Ratings: +118

View Profile
« Reply #132 on: 09 September, 2010, 03:59:08 »
0

This is only a problem when the flag -nostdlib is added to the ld part of the makefile (I discovered it when ExtendeD suggested it as a fix to the "random" large file size).

When I remove the flag, everything is fine.

EDIT:  Also, the program that gives that error (Trapped) does not even use the static library (I have been too lazy to change it over).
« Last Edit: 09 September, 2010, 03:59:59 by apcalc » Logged


ExtendeD
Coder Of Tomorrow
LV8 Addict (Next: 1000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:41:25
Date Registered: 02 January, 2010, 13:03:41
Location: France
Posts: 766

Total Post Ratings: +151

View Profile
« Reply #133 on: 09 September, 2010, 20:49:00 »
0

gcc will sometimes emit calls to memset or memcpy functions if you initialize or assign large structures. Having them as macros won't help. I think we need to have real memset and memcpy functions in the library (even if all they do is call the OS functions).

In the next release of Ndless, OS calls will be defined as static inline functions. I'm not sure how GCC will react in this case.
Logged

ndlessly - Progress and insights on Ndless
Ndless / Hackspire - Third-party TI-Nspire development
qazz42
LV9 Veteran (Next: 1337)
*********
Offline Offline

Last Login: 29 December, 2012, 01:39:31
Date Registered: 19 June, 2010, 16:06:31
Posts: 1134


Total Post Ratings: +17

View Profile
« Reply #134 on: 09 September, 2010, 21:04:11 »
0

hmm, good to hear that ndless is being worked on still Tongue
Logged

Pages: 1 ... 7 8 [9] 10 11 ... 13   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.304 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.