All Posts (blitter)




#1
Re: gccVB 4 and PC-relative calls/jumps
Posted on: 1/27 4:03
Nintendoid!
Joined 2007/12/14
116 Posts
CoderLong Time User (7 Years) App Coder
D'oh, I meant MinGW. Whenever I use the GCC suite in Windows I'm conditioned to assume it's Cygwin.

And yeah, 32-bit multi-char literals have been a staple of Mac development since the dawn of time. Tells you where I wrote it. ;)
Top

Topic | Forum


#2
Re: gccVB 4 and PC-relative calls/jumps
Posted on: 1/25 10:17
Nintendoid!
Joined 2007/12/14
116 Posts
CoderLong Time User (7 Years) App Coder
I know that linker order can affect the visibility of symbols across object files, but I've never before seen a case where the order can directly affect the addresses generated for visible symbols. I fear something more sinister is at play here. At any rate, switching the linker order can appear to fix some instances of this problem, but I've run into this when building assembly-based projects too, where multiple symbols may be defined within a single translation unit, and a deliberate order determines where the assembly is placed in the binary. Changing the linker order here means changing the layout of the binary, which in my case could break execution since pieces of my code expect functions to live in certain areas of ROM.

That said, and since I have not the desire to dig into GCC to find the root cause of this (I'd rather be developing for the VB itself), I decided to hack my way around this problem by writing a small tool that patches ELF files with bad jumps. As an example:


mbp
:jmptool blitter$ ./jmptool ../../isrtest/output/IsrTest.elf IsrTest_fixed.elf
Total ELF sections
12
Last ELF section address is 0x0707FDE0
size is 0x00000220last byte 1 is 0x07080000
disp26 mask is 0x0007FFFF
disp26 shift is 7
Found a bad jump at 0x0700003A
jr    0x07400022 [(int26)0x003FFFE8]
    
Correcting to 0x07000022 [(int26)0x03FFFFE8]
Found a bad jump at 0x070000ACjr    0x07400022 [(int26)0x003FFF76]
    
Correcting to 0x07000022 [(int26)0x03FFFF76]
Found a bad jump at 0x07003472jal    0x07403404 [(int26)0x003FFF92]
    
Correcting to 0x07003404 [(int26)0x03FFFF92]
mbp:jmptool blitter$

Keen eyes may notice that the bad jumps are 8 bits away from their corrected versions-- the bad jumps are coded as 18-bit displacements when they should be 26-bit. Maybe this can help somebody (dasi? Guy Perfect?) but I've given up solving this problem since GCC is quite the complicated beast and this tool works well enough when stuck between ld and objcopy. :)

I built this tool for OS X and also in Cygwin on my Windows 8.1 machine, but the source is included too just in case. Hope this helps someone else out there.

Attach file:


zip jmptool.zip Size: 46.40 KB; Hits: 9
Top

Topic | Forum


#3
Re: Game idea & mockup thread
Posted on: 1/13 4:55
Nintendoid!
Joined 2007/12/14
116 Posts
CoderLong Time User (7 Years) App Coder
+1 for Tempest/T3K. I wonder if Jeff Minter would consider a VB side project...
Top

Topic | Forum


#4
Re: Which way do your VB legs go?
Posted on: 2014/12/31 18:06
Nintendoid!
Joined 2007/12/14
116 Posts
CoderLong Time User (7 Years) App Coder
I believe Nintendo's sanctioned way according to the manual is with the legs pointing away from you, so that the controller is behind the system and you look like you're "hugging" the VB while in use. I play this way and it's very comfortable. Holding the controller in front of me with the legs pointing towards my body makes me feel like I have T-rex arms and gets tiresome after a while.
Top

Topic | Forum


#5
Re: Super Mario Bros, Virtual Boy
Posted on: 2014/10/22 7:42
Nintendoid!
Joined 2007/12/14
116 Posts
CoderLong Time User (7 Years) App Coder
Probably fake. At 0:53 you can see the left half of the Goomba's sprites disappear as it moves offscreen-- This happens naturally on the NES but is a rendering artifact very unlikely to survive in an engine rewrite, which a port to the VB would require.
Top

Topic | Forum


#6
Re: gccVB optimization options and assembly code
Posted on: 2014/10/19 22:57
Nintendoid!
Joined 2007/12/14
116 Posts
CoderLong Time User (7 Years) App Coder
Quote:

cr1901 wrote:
I HATE to be the one to bring this up, but perhaps it's time that some of us take a look at GCC internals to see what's going wrong? I'm taking a bit of a break from VB coding (call it "guilt that I'm letting my other code rot") anyway, and I probably could take a look if I had some code that is known to generate bad jumps.


If somebody wanted to take a look at the GCC 4 patches, I know of a few spots that look suspicious:

- The "return "movhi hi(%1),%.,%0\n\tmovea lo(%1),%0,%0";" in output_move_single, line 2255 or thereabouts in gcc-4.4.2-vb.patch. 32-bit loads are always encoded this way, even if the high word doesn't change between consecutive loads. This line also shows up elsewhere in that function for handling other such loads.

- "sprintf (buff, "mov r31,r10\n\tmovhi hi(%s), r0, r11\n\tmovea lo(%s), r11, r11\n\tjal .+4\n\tadd 4, r31\n\tjmp r11", name, name);" in construct_save_jarl, line 3797 or so also in gcc-4.4.2-vb.patch. While this isn't bogus code-- this code works-- I don't think we need to be doing long jumps in this way since jal takes up to a 26-bit displacement, which if my math is correct means up to an almost 64MByte jump in either direction-- well more than we need on the VB.

- Prologue and epilogue function generation. Building with -O3 or -Os in gccVB 4.8 (part of dasi's devkitV810 WIP) is totally broken here, generating unnecessary epilogue functions that clobber lp, leading to subroutines that in my testing return to address 0 (the first framebuffer), causing a crash. This can also happen occasionally in gccVB 4.4.2, though I haven't been able to create a minimal example yet.

- Lines 837-849 in binutils-2.20-vb.patch, beginning with "HOWTO (R_V810_9_PCREL,": This might be what's causing the bad jump logic, creating relative jump addresses that are multiples of 0x400000 from what they should be, eventually wrapping around to the beginning of the address space and crashing. Not sure why the entry for 9-bit branches uses 26 for bitsize and type 'long.' I posted some code that exhibits this bug a while ago-- http://www.planetvb.com/modules/newbb ... t_id=26069#forumpost26069 -- would be happy if somebody took a good hard look at what's going on. (EDIT: It might just be a linker order problem, but would be nice to know for sure.)

:)
Top

Topic | Forum


#7
Re: gccVB optimization options and assembly code
Posted on: 2014/10/19 5:54
Nintendoid!
Joined 2007/12/14
116 Posts
CoderLong Time User (7 Years) App Coder
Some of it yes, some of it no. I've thought of this-- in fact I wrote a tool that post-processes my ROM to poke addresses directly into the assembly, saving runtime lookups-- but any processing that adds or removes instructions would be non-trivial since that would throw any other instructions that deal with addresses completely out of whack.
Top

Topic | Forum


#8
Re: Getting started... on Linux?
Posted on: 2014/10/18 6:23
Nintendoid!
Joined 2007/12/14
116 Posts
CoderLong Time User (7 Years) App Coder
Quote:

Greg Stevens wrote:
Im pretty sure blitter was referring to the "precompiled version" that DaVince mentioned which is 2.95. But he can correct me if I am wrong. However I would like to note that the version with VBDE as I and blitter have pointed out in other posts doesn't compile with the most optimal code for whatever reasons. Whether its the patches or something inherant in gccvb 4 is probably still an outstanding question. I setup a windows vm and installed cygwin just to compile with the 2.95 version because the compiled code was roughly 5 times faster than with the newer version. Things like using "inline" on a function which should cause the compiler to inject the function inline still produce normal function jump and return code in VBDE. Of course I don't know enough about gcc to even guess at where to look for that kind of stuff.


By default I don't think gccvb 4 builds with any optimizations. Building with -O3 or sometimes -Os can generate really performant code. However like we've mentioned there are still some outstanding bugs. gccvb 4 also has the ability to strip out code that isn't used, resulting in a smaller .text section and therefore more room for other goodies in .data and .rodata.
Top

Topic | Forum


#9
Re: Getting started... on Linux?
Posted on: 2014/10/18 6:18
Nintendoid!
Joined 2007/12/14
116 Posts
CoderLong Time User (7 Years) App Coder
Quote:

DaVince wrote:
I guess you're talking about this? I cloned the Git repo and at least now I understand what libgccVB is for. And that I need v810-gcc, which fails to compile (at least the version included in the gccVB 2.95 source).


Was referring to the compiler suite, but since it's mentioned, the libgccvb headers I use are based on a really old set. I basically only use them for the equates and const mappings-- setting up the column table is done in my crt0.s and the remaining functionality I rewrite to fit whatever project I'm working on.
Top

Topic | Forum


#10
Re: Getting started... on Linux?
Posted on: 2014/10/17 4:13
Nintendoid!
Joined 2007/12/14
116 Posts
CoderLong Time User (7 Years) App Coder
I can't speak for that ancient version of GCC since I've never bothered with it, but the executables for gccVB 4 are prefixed with "v810-" so they don't interfere with the system version. In any case, the make_v810.sh script installs everything to /opt/gccvb so it's contained in its own directory, but that's easily changed by editing the script yourself.

There's a bit of an effort to stabilize gccVB 4 (It's functional, but has a few outstanding issues) so that's probably why it's not in the Tools area yet. If you're feeling adventurous you can search the forums for the patches and build it yourself...
Top

Topic | Forum




You are not logged in.
Lost Password?
Register Resend Activation