English
Language : 

45111 Datasheet, PDF (68/184 Pages) List of Unclassifed Manufacturers – 14-DAY MONEY BACK GUARANTEE
7 The SASM Assembler
When this macro is used in a program to be run on an SX48/52, it is necessary that the symbol SX48_52
is defined prior to the first invocation of the _bank macro.
7.4.13 Macros with Formal Parameters by Name
This is an example for a macro with one named parameter:
delay MACRO cycles
IF (cycles > 0)
REPT (cycles/3)
jmp $+1
ENDR
REPT (cycles//3)
nop
ENDR
ENDIF
ENDM
; delay 3 cycles
; delay 1 cycle
When invoked with
delay 7
the word “cycles” is replaced by 7 and the macro expands into
IF (7 > 0)
REPT (7/3)
jmp $+1
jmp $+1
ENDR
REPT (7//3)
nop
ENDR
ENDIF
; delay 3 cycles
; delay 3 cycles
; delay 1 cycle
The macro operates by generating as many JMP $+1 instructions as possible to use the bulk of the delay
at a cost of one instruction word per three clock cycles then make up the balance with NOP instructions.
For example, delay 6 would not generate NOP instructions at all but just two jmp $+1 instructions,
where delay 8 would generate two jmp $+1 and two NOP instructions. In case of cycles = 0, no code is
generated at all.
7.5 Symbols
Symbols are descriptive names for numeric values. Symbol names can consist of up to 32 alphanumeric
and underscore (_) characters and must start with a letter or underscore. SASM expects symbol
declarations to start in column 1 of the program line. Symbols for constants are usually defined near the
start of assembly source code using the equal directive EQU. For example:
Page 68 • SX-Key/Blitz Development System Manual 2.0 • Parallax, Inc.