Hi all,
Trying to write a simple memory test for the TRS-80 in C. I wasn to avoid testing the area the program is loaded into, and any of it's data.
Is there a way to get the program's start and end addresses and likewise for the data / variables areas?
Cheers.
Phill.
Start and end address of program and data areas...
Re: Start and end address of program and data areas...
The program will be contained between the assembler symbols CRT_ORG_CODE and __BSS_END_tail.
Re: Start and end address of program and data areas...
Try something like the following (I've switched to __head rather than CRT_ORG_CODE since CRT_ORG_CODE isn't exported):
Note that this only works for non-ROM compilations (not that that's an issue for the trs80).
Note that this only works for non-ROM compilations (not that that's an issue for the trs80).
Code: Select all
; misc.asm:
SECTION code_user
GLOBAL _get_program_start
GLOBAL _get_program_end
GLOBAL __head
GLOBAL __BSS_END_tail
_get_program_start:
ld hl,__head
ret
_get_program_end:
ld hl,__BSS_END_tail
ret
Code: Select all
// misc.h
extern void *get_program_start(void);
extern void *get_program_end(void);
Code: Select all
//main.c
#include <stdio.h>
#include "misc.h"
int main() {
printf("Start %p\n",get_program_start());
printf("End %p\n",get_program_end());
}
Re: Start and end address of program and data areas...
Thanks for that dom, that's exactly what I needed.
Cheers.
Phill.
Cheers.
Phill.