File: mem.c

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (47 lines) | stat: -rw-r--r-- 1,423 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
** show some memory stuff
**
** 04-Aug-2004, Christian Groessler
*/

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <atari.h>
#include <cc65.h>

extern int getsp(void);                         /* comes from ../getsp.s */

unsigned char data = 0x12;                      /* data variable */

unsigned int *APPMHI = (unsigned int *)14;      /* 14,15 */
unsigned char *RAMTOP = (unsigned char *)106;   /* in pages */
unsigned int *LOMEM = (unsigned int *)128;      /* used by BASIC */
unsigned int *MEMTOP = (unsigned int *)741;
unsigned int *MEMLO = (unsigned int *)743;
void *allocmem;

int main(void)
{
  allocmem = malloc(257);

  clrscr();

  printf("  RAMTOP = %02X (%u) - $%04X (%u)\n",
         *RAMTOP, *RAMTOP, *RAMTOP * 256, *RAMTOP * 256);
  printf("  APPMHI = $%04X (%u)\n", *APPMHI, *APPMHI);
  printf("  LOMEM  = $%04X (%u)  <BASIC only>\n", *LOMEM, *LOMEM);
  printf("  MEMTOP = $%04X (%u)\n", *MEMTOP, *MEMTOP);
  printf("  MEMLO  = $%04X (%u)\n", *MEMLO, *MEMLO);

  printf("  ----------------------\n");
  printf("  main:            $%04X  (code)\n", &main);
  printf("  data:            $%04X  (data)\n", &data);
  printf("  _dos_type:       $%04X  (bss)\n", &_dos_type);
  printf("  allocmem:        $%04X  (dyn. data)\n", allocmem);
  printf("  sp:              $%04X  (stack ptr)\n", getsp());

  if (allocmem) free(allocmem);
  if (doesclrscrafterexit()) cgetc();
  return(0);
}