]> git.sur5r.net Git - cc65/blob - testcode/lib/atari/mem.c
Merge remote-tracking branch 'upstream/master' into creativision
[cc65] / testcode / lib / atari / mem.c
1 /*
2 ** show some memory stuff
3 **
4 ** 04-Aug-2004, Christian Groessler
5 */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <conio.h>
10 #include <atari.h>
11 #include <cc65.h>
12
13 extern int getsp(void);                         /* comes from ../getsp.s */
14
15 unsigned char data = 0x12;                      /* data variable */
16
17 unsigned int *APPMHI = (unsigned int *)14;      /* 14,15 */
18 unsigned char *RAMTOP = (unsigned char *)106;   /* in pages */
19 unsigned int *LOMEM = (unsigned int *)128;      /* used by BASIC */
20 unsigned int *MEMTOP = (unsigned int *)741;
21 unsigned int *MEMLO = (unsigned int *)743;
22 void *allocmem;
23
24 int main(void)
25 {
26   allocmem = malloc(257);
27
28   clrscr();
29
30   printf("  RAMTOP = %02X (%u) - $%04X (%u)\n",
31          *RAMTOP, *RAMTOP, *RAMTOP * 256, *RAMTOP * 256);
32   printf("  APPMHI = $%04X (%u)\n", *APPMHI, *APPMHI);
33   printf("  LOMEM  = $%04X (%u)  <BASIC only>\n", *LOMEM, *LOMEM);
34   printf("  MEMTOP = $%04X (%u)\n", *MEMTOP, *MEMTOP);
35   printf("  MEMLO  = $%04X (%u)\n", *MEMLO, *MEMLO);
36
37   printf("  ----------------------\n");
38   printf("  main:            $%04X  (code)\n", &main);
39   printf("  data:            $%04X  (data)\n", &data);
40   printf("  _dos_type:       $%04X  (bss)\n", &_dos_type);
41   printf("  allocmem:        $%04X  (dyn. data)\n", allocmem);
42   printf("  sp:              $%04X  (stack ptr)\n", getsp());
43
44   if (allocmem) free(allocmem);
45   if (doesclrscrafterexit()) cgetc();
46   return(0);
47 }