Knowing the highest address of a C executable

Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
User avatar
Hialmar
Flight Lieutenant
Posts: 349
Joined: Tue Mar 04, 2014 11:25 am
Location: Toulouse, France
Contact:

Knowing the highest address of a C executable

Post by Hialmar »

Is there a way to find it ?

Or should I compute it with "start address" + "size of executable" ?

For example, my program starts at 0x600 and once I compile it I get:

File 'build\laby.tap' is 15352 bytes long (14 bytes header and 15338 bytes of data)

So is it correct if I do :
15338 = 0x3BEA

0x600 + 0x3BEA = 0x41EA is the end address ?
Hialmar
CEO and Silicium member.
User avatar
peacer
Flight Lieutenant
Posts: 451
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: Knowing the highest address of a C executable

Post by peacer »

You can check it with oric explorer maybe?

http://oric.mrandmrsdavies.com/
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Knowing the highest address of a C executable

Post by Chema »

There is a label at the end of the generated assembly file called osdk_end, but as it does not have any preceeding underscore, I guess you cannot access it directly from your C source.

Anyway you can run osdk_showmap to see how your program is stored, including labels as osdk_end.
User avatar
Hialmar
Flight Lieutenant
Posts: 349
Joined: Tue Mar 04, 2014 11:25 am
Location: Toulouse, France
Contact:

Re: Knowing the highest address of a C executable

Post by Hialmar »

Thanks a lot. I'll do that.

Edit: it says $41ea as I computed so that's consistent :)
Hialmar
CEO and Silicium member.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Knowing the highest address of a C executable

Post by Dbug »

Well, depend of what you mean by 'highest address'.

What you will find with your method is the position of the last byte of the executable, which basically is the end of the TEXT/DATA sections, if the program uses the BSS to declare arrays, it may not work.

I guess knowing what you want to do would help giving a better answer :)
User avatar
Hialmar
Flight Lieutenant
Posts: 349
Joined: Tue Mar 04, 2014 11:25 am
Location: Toulouse, France
Contact:

Re: Knowing the highest address of a C executable

Post by Hialmar »

Well basically it's to find out if I still have some memory space left to do other things.
Hialmar
CEO and Silicium member.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Knowing the highest address of a C executable

Post by Dbug »

Hialmar wrote:Well basically it's to find out if I still have some memory space left to do other things.
Then I really recommend that you use OSDK_SHOWMAP.BAT, it will generate a html page with the list of all the addresses, zero page, overlay memory, and what is aligned or not.
User avatar
Hialmar
Flight Lieutenant
Posts: 349
Joined: Tue Mar 04, 2014 11:25 am
Location: Toulouse, France
Contact:

Re: Knowing the highest address of a C executable

Post by Hialmar »

Ok thanks that's what I did and it's very interesting indeed.
Hialmar
CEO and Silicium member.
Post Reply