Page 1 of 1

Knowing the highest address of a C executable

Posted: Sat May 03, 2014 11:10 am
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 ?

Re: Knowing the highest address of a C executable

Posted: Sat May 03, 2014 11:20 am
by peacer
You can check it with oric explorer maybe?

http://oric.mrandmrsdavies.com/

Re: Knowing the highest address of a C executable

Posted: Sat May 03, 2014 12:00 pm
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.

Re: Knowing the highest address of a C executable

Posted: Sat May 03, 2014 1:13 pm
by Hialmar
Thanks a lot. I'll do that.

Edit: it says $41ea as I computed so that's consistent :)

Re: Knowing the highest address of a C executable

Posted: Sat May 03, 2014 5:22 pm
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 :)

Re: Knowing the highest address of a C executable

Posted: Sat May 03, 2014 8:14 pm
by Hialmar
Well basically it's to find out if I still have some memory space left to do other things.

Re: Knowing the highest address of a C executable

Posted: Sat May 03, 2014 9:28 pm
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.

Re: Knowing the highest address of a C executable

Posted: Sun May 04, 2014 7:28 am
by Hialmar
Ok thanks that's what I did and it's very interesting indeed.