[stella] EQU and DS

Subject: [stella] EQU and DS
From: jimn8@xxxxxxxxxx (Jim Nitchals)
Date: Thu, 17 Oct 1996 18:34:05 -0700 (PDT)
These are instructions to the assembler.  EQU is designed to assign a value
to a name, and DS is designed to reserve space.

VSYNC EQU $00  tells the assembler that when you say VSYNC, you mean memory
at address $00.  For example, the instruction


will be interpreted by the assembler to mean STA $00.  The Atari 2600's
video hardware looks like memory to the 6502, so the memory locations
$00 through $7F are accessing 2600 hardware.  Locations $80 through $FF
are genuine RAM addresses, usable for your game.

If we were programming in C, we might've said:
#define VSYNC 0x00

The DS instruction tells the assembler how much space to set aside at the
current address.  Let's say you need 16 bytes for a list of where all the
chess pieces are in a game.  The data will need to go into RAM, so just
tell the assembler:
                org $80
ListOfPieces	DS  16
OtherVariable   DS  1
TEMP            DS  2

This is easier than saying:
ListOfPieces    EQU $80
OtherVariable   EQU $90
TEMP            EQU $91

and less error-prone.

The Supercharger has RAM in the memory areas normally set aside for ROM
at locations $F000 thru $FFFF.  The DS command can be used to reserve
space for data storage in the Supercharger memory also, but you'll need
to follow the instructions for storing data there (STA doesn't work.)

Communist Mutants From Space (on the Supercharger CD in /source/finalgam.src
in the file COMMIE.ASM) uses the DS command to reserve space for many of
its variables.  The 128 bytes of RAM in the 2600 just aren't enough to
keep track of multiple shots, aliens, graphics, and other data needed,
so Commie Mutants stores some of this data in bank 3 of Supercharger RAM.

Current Thread