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 !
Post Reply
User avatar
Hialmar
Flight Lieutenant
Posts: 318
Joined: Tue Mar 04, 2014 11:25 am
Location: Toulouse, France
Contact:

Knowing the highest address of a C executable

Post by Hialmar » Sat May 03, 2014 11:10 am

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: 351
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: Knowing the highest address of a C executable

Post by peacer » Sat May 03, 2014 11:20 am

You can check it with oric explorer maybe?

http://oric.mrandmrsdavies.com/

User avatar
Chema
Game master
Posts: 2078
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 » Sat May 03, 2014 12:00 pm

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: 318
Joined: Tue Mar 04, 2014 11:25 am
Location: Toulouse, France
Contact:

Re: Knowing the highest address of a C executable

Post by Hialmar » Sat May 03, 2014 1:13 pm

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: 2387
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Knowing the highest address of a C executable

Post by Dbug » Sat May 03, 2014 5:22 pm

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: 318
Joined: Tue Mar 04, 2014 11:25 am
Location: Toulouse, France
Contact:

Re: Knowing the highest address of a C executable

Post by Hialmar » Sat May 03, 2014 8:14 pm

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: 2387
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Knowing the highest address of a C executable

Post by Dbug » Sat May 03, 2014 9:28 pm

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: 318
Joined: Tue Mar 04, 2014 11:25 am
Location: Toulouse, France
Contact:

Re: Knowing the highest address of a C executable

Post by Hialmar » Sun May 04, 2014 7:28 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests