Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2020-06-28 22:01:05

alchemypotofficial
New member
Registered: 2020-06-28
Posts: 4

Relocation Error - Solved

Does anyone recognize this error and or know how to fix it?
Thanks in advance!~

"lcc31121.asm:3407: Error: <r> relocation error"

Last edited by alchemypotofficial (2020-06-29 19:23:00)

Offline

 

#2 2020-06-29 07:06:51

toxa
Member
Registered: 2020-02-13
Posts: 304

Re: Relocation Error - Solved

that error means, that assembler fails to compile the asm-code generated by C compiler from your source. the manual says:

Code:

              (r)   Relocation  error:   logic  operation attempted on a
                    relocatable term, addition of two relocatable terms,
                    subtraction  of two relocatable terms not within the
                    same programming area or external symbols.

it's hard to tell what's wrong in your case without code and versions of gbdk/sdcc.

Offline

 

#3 2020-06-29 16:16:54

alchemypotofficial
New member
Registered: 2020-06-28
Posts: 4

Re: Relocation Error - Solved

Thanks for the reply, I think that error code explanation gives me a hint at what's actually going on. I will post more about what my problem exactly is when I find the offending code. Cheers!

Offline

 

#4 2020-06-29 19:22:35

alchemypotofficial
New member
Registered: 2020-06-28
Posts: 4

Re: Relocation Error - Solved

I believe the error was caused by doing addition or subtraction from within the index brackets of a matrix. Doing arithmetic outside of the array and then passing the variable into the index seems to fix this problem.

This was the offending code -

extern const unsigned char Tileset_1_Map[42][4];
...

void Draw_Tile8(UBYTE tile_x, UBYTE tile_y, UBYTE tile_num)
{
    set_bkg_tiles(tile_x, tile_y, 2, 2, Tileset_1_Map[tile_num]);
}
...

Draw_Tile8(load_pos_x, i, map->data[map_x + map_y]);
map_y += map_size_x;

Last edited by alchemypotofficial (2020-06-29 19:27:19)

Offline

 

#5 2020-06-30 03:48:55

toxa
Member
Registered: 2020-02-13
Posts: 304

Re: Relocation Error - Solved

what gbdk version do you use?

Offline

 

#6 2020-06-30 04:03:48

alchemypotofficial
New member
Registered: 2020-06-28
Posts: 4

Re: Relocation Error - Solved

GBDK 2.95-3, the last version updated. Is there actually a newer release besides GBDK 2020? I've been planning on switching to GBDK 2020 but haven't gotten around to it.

Last edited by alchemypotofficial (2020-06-30 04:04:53)

Offline

 

#7 2020-06-30 04:38:15

toxa
Member
Registered: 2020-02-13
Posts: 304

Re: Relocation Error - Solved

you should switch to GBDK-2020, that problems you have because of ancient SDCC. that's not the only bug in it. you may find the latest release of GBDK-2020 here: https://github.com/Zal0/gbdk-2020/releases

as an alternative, you may use gbdk-n with the standalone SDCC, but there are problems with the library and no memory banking support

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson