You are not logged in.
Lost Password?


Register To Post



 Bottom   Previous Topic   Next Topic

#1
gccVB optimization options and assembly code
Posted on: 2013/2/9 14:05
PVB Elite
Joined 2008/12/28
Slovenia
625 Posts
Highscore Top ScoreHighscore Top ScoreCoderContributor10+ Game RatingsLong Time User (10 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
Is there a way to use the optimization options with gccVB? Both versions I have (1.0 and the one distributed with the latest VBDE) give me linker errors when I use them:

Version 1.0:

C:\DOCUME~1\USER\LOCALS~1\Temp\ccQZaaaa.o: In function `main':
C:\DOCUME~1\USER\LOCALS~1\Temp\ccQZaaaa.o(.text+0x81a): undefined reference to `
_save_r28_r31'
C:\DOCUME~1\USER\LOCALS~1\Temp\ccQZaaaa.o(.text+0x81a): relocation truncated to
fit: R_V810_26_PCREL _save_r28_r31

VBDE version:

C:\DOCUME~1\USER\LOCALS~1\Temp\ccrWXelX.o: In function `main':
GAME.c:(.text+0x84a): undefined reference to `_save_r27_r31'
GAME.c:(.text+0x84a): relocation truncated to fit: R_V810_26_PCREL against undefin
ed symbol `_save_r27_r31'
collect2: ld returned 1 exit status
make.exe: *** [GAME.o] Error 1
Could Not Find W:\GAME\GAME.o

Also, how would I link assembly code (or code produced by another compiler) with C code and what tools do I have to use?
Top

#2
Re: gccVB optimization options and assembly code
Posted on: 2013/2/9 18:53
PVB Elite
Joined 2011/7/1
Germany
1099 Posts
CoderContributorTop10 PosterLong Time User (7 Years) App CoderPVBCC 2013 Entry
Are you using the linker script dasi published?
Top

#3
Re: gccVB optimization options and assembly code
Posted on: 2013/2/9 18:55
PVB Elite
Joined 2008/12/28
Slovenia
625 Posts
Highscore Top ScoreHighscore Top ScoreCoderContributor10+ Game RatingsLong Time User (10 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
I'm just using whatever came with the releases.
Top

#4
Re: gccVB optimization options and assembly code
Posted on: 2013/2/9 19:01
PVB Elite
Joined 2011/7/1
Germany
1099 Posts
CoderContributorTop10 PosterLong Time User (7 Years) App CoderPVBCC 2013 Entry
Make sure you have the linker script from this thread http://www.planetvb.com/modules/newbb ... t_id=20963#forumpost20963 referenced in your makefile.
Top

#5
Re: gccVB optimization options and assembly code
Posted on: 2013/2/9 19:24
PVB Elite
Joined 2008/12/28
Slovenia
625 Posts
Highscore Top ScoreHighscore Top ScoreCoderContributor10+ Game RatingsLong Time User (10 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
Still getting the same error. Yes, I did run crt0_make.bat.
Top

#6
Re: gccVB optimization options and assembly code
Posted on: 2013/3/1 4:48
Nintendoid!
Joined 2012/8/5
USA
117 Posts
CoderLong Time User (6 Years) PVBCC 2013 3rd
I'm not going to pretend to be an expert on compiler options but I reproduced the error you were getting and seemed to have worked around it by setting the optimization flags manually. Here is my gcc command with all the flags that would normally be set using -O (minus the ones that weren't supported by this version). The following is what I now have in my makefile for the VBDE and I was able to compile the program I've been working on without getting those errors.

All the flag information I got from

http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

v810-gcc.exe -Wall -fomit-frame-pointer -funit-at-a-time -ftree-ter -ftree-sra -ftree-fre -ftree-dse -ftree-copyrename -ftree-dominator-opts -ftree-ch -ftree-builtin-call-dce -fsplit-wide-types -fmerge-constants -fmerge-constants -fipa-reference -fipa-pure-const -fif-conversion -fif-conversion2 -fguess-branch-probability -fdse -fdefer-pop -fdce -fcprop-registers -fauto-inc-dec -Xassembler -a=game.lst -nodefaultlibs -mv810 -Tc:/vbde/gccvb/v810/lib/vb.ld -xc -o game.o game.c
Top

#7
Re: gccVB optimization options and assembly code
Posted on: 2013/3/2 12:56
PVB Elite
Joined 2008/12/28
Slovenia
625 Posts
Highscore Top ScoreHighscore Top ScoreCoderContributor10+ Game RatingsLong Time User (10 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
This works great. Thank you very much.

I measured a difference of about 3K between optimized and unoptimized ROM images, probably because of unused libgccvb functions.
Top

#8
Re: gccVB optimization options and assembly code
Posted on: 2013/3/30 0:06
PVB Elite
Joined 2003/7/26
USA
1455 Posts
PVBCC EntryCoderContributorSpecial AchievementTop10 PosterHOTY09 EntryLong Time User (15 Years) App Coder20+ Game RatingsPVBCC 2013 Entry
Quote:

HorvatM wrote:

Also, how would I link assembly code (or code produced by another compiler) with C code and what tools do I have to use?


If you're using GCC assembly, you can just specify the .s file as one of the input files and it should be assembled and linked automatically, depending on the options specified; e.g. it won't work if you use -x to turn off automatic language detection.

If it's a binary produced by another compiler (or by hand) it has to be in a format gcc understands (couldn't find a list, but ELF, COFF and possibly a.out should work). If it's just a raw binary, you could turn it into an array and use an asm block to jump into it, put it would have to be position-independent code (i.e. using relative jumps). What non-gcc tools do you have that produce VB (NVC/v810) machine code?
Top

#9
Re: gccVB optimization options and assembly code
Posted on: 2013/3/30 18:55
PVB Elite
Joined 2008/12/28
Slovenia
625 Posts
Highscore Top ScoreHighscore Top ScoreCoderContributor10+ Game RatingsLong Time User (10 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
Quote:

RunnerPack wrote:
If you're using GCC assembly, you can just specify the .s file as one of the input files and it should be assembled and linked automatically, depending on the options specified; e.g. it won't work if you use -x to turn off automatic language detection.

That's cool, but I'm planning to write my own assembler and I don't like GCC syntax much (that's not the only reason for writing it though). But it shouldn't be too hard to write a converter from my syntax to GCC syntax.
Quote:

What non-gcc tools do you have that produce VB (NVC/v810) machine code?

None [yet], but reading the veCC readme made me think about writing a compiler for BASIC or another language (even though I'm not an expert on compilers). But there isn't any demand for one anyway.
Top

#10
Re: gccVB optimization options and assembly code
Posted on: 2014/3/22 16:23
Nintendoid!
Joined 2012/8/5
USA
117 Posts
CoderLong Time User (6 Years) PVBCC 2013 3rd
For all of us using VBDE I think we need to revisit the optimization errors received when adding -O to the gcc compiler options. This last coding competition taught me something extremely important. The old compiler (Which at least DanB is still using) works with the -O compiler option. IT MAKES A HUGE DIFFERENCE in code performance. The options I found and added in this post don't even begin to touch the performance of the old compiler with -O. I compiled my wireframe library using the old compiler (v2.95) and my code instantly ran 4-5 TIMES faster than running my code using the assembly versions of my functions on the compiler packaged with VBDE.

Unfortunately I'm a linux geek and compiling on my system isn't going to benefit too many people other than myself.

I tried once to compile gcc using patches that I found on this site from other posts but have never been successful. There's always something that comes up that I have no idea how to fix. (Of course I'm a total amateur at C and C++ so that's not really saying much).

Thanks to Thunderstruck for compiling DanB's zpace racers and pointing out on the forum that it ran much slower than DanB's demo. That little nugget directed me to try my code on the old compiler which I had never tried before.

For now, I'll be switching back to the old compiler version because I can basically eliminate all of my assembly routines and code directly in C since the performance difference is not noticable when using the -O or compiling with my assembly version functions.
Top

 Top   Previous Topic   Next Topic


Register To Post