SPASM General Info

SPASM is a z80 assembler with extra features to support development for TI calculators.  SPASM was written not to add another generic tool to the oversaturated assembler "marketplace," but to actually do something different. I needed a fast assembler. TASM wasn't cutting it. When you're impatient, you debug often, or are writing too much code for other assemblers to handle, this assembler is your new best friend.


Labels in SPASM are much like TASM 3.2. The preferred style of label is the colon terminated, like this:

	ld a,30

;With labels, you can use this syntax:

Label2:	ld a,25 \ ret

Also permitted is the non-colon terminated line label.

	xor a
	ld (ram_loc),a

;Like above, the following is acceptable:

label2	inc a
	ld (ram_loc+1),a


SPASM uses no-questions-asked order of operations: left-to-right. This is prefered for speed reasons as well as ambiguity between operators -- who really knows which of these operators should come first? % or &?

The operators available are as follows: * / - + % ^ & | << >>

 ld a,10*15		;= 150  multiply
 ld b,254/12		;= 12   integer divide (it truncates)
 ld c,10-30		;= -20  subtract
 ld d,-(10-23)		;= 13   negate
 ld e,10+10		;= 20   addition
 ld h,10^3		;= 9    bitwise exclusive or
 ld l,17 & 1		;= 1    bitwise and
 .db 10 | 5		;= 15   bitwise or
 .dw 1<<4		;= 16   arithmetic left shift
 ld hl,16>>4		;= 1    arithmetic right shift

;Example of order of operations:

 ld hl,25*256+10	;h = 25, l = 10
 ld hl,10+25*256	;h = 350,l = 0
 ld hl,10+(25*256)	;h = 25, l = 10


SPASM macros were built to be fast, more than anything else. I generally preserve the functionality of other assemblers while keeping it simple. There are three types of macros, invoked by the preprocess keyword #define or in the case of argumented macros #macro. Refer to the #macro documentation for more info.

  • Dimensionless Macros (Boolean Defines)
  • Replacement Macros (Defines)
  • Argumented Replacement Macros

Macros of this nature are not defined explicitly by the programmer, rather they are set to an arbitrary default. SPASM uses these as a quick Boolean Define for the #IFDEF preprocess.

#define on_emulator

#ifdef on_emulator
	push de
	pop ix
	ld ixl,e
	ld ixh,d

Replacement: Replacement macros are the equivalent of a "named" copy and paste. They are not parsed until they are substituted, so they're ideal for making forward label references. Keep in mind that they can only make forward references to other defines as long as the define does not reference them in return.

#define value 56
#define other_value value+10

;Defines like these can be used in the #IF preprocess:
#if other_value > value
	.dw other_value
	.dw value

Argumented Replacement:
The most complex of the macros, argumented replacement macros allows certain values of replacement macro to be changed before parsing. This allows the same macro to be used under multiple circumstances.

#macro my_modulo(base, mod)
 base - (base*(base/mod))
#define llo(val) (val & $FF)
 .db llo( my_modulo(10,3))
 .db my_modulo(10,3)

Last edited Oct 8, 2010 at 4:19 PM by sputt, version 14


No comments yet.