English
Language : 

45111 Datasheet, PDF (67/184 Pages) List of Unclassifed Manufacturers – 14-DAY MONEY BACK GUARANTEE
7 The SASM Assembler
7.4.12 Macros with Formal Parameters by Count
The following is a sample for a macro with one formal parameter:
; Sets the bank appropriately for all types of SX controllers
;
_bank macro 1
bank \1
IFDEF SX48_52
IF \1 & %10000000
; SX48BD and SX52BD bank instruction
setb fsr.7
; modifies FSR bits 4,5 and 6. FSR.7 needs to be set
; by software.
ELSE
clrb fsr.7
ENDIF
ENDIF
endm
This macro is useful to replace the BANK instruction in programs that shall be running on SX48/52
devices as well as on “smaller” chips. The BANK instruction only affects FSR bits 4, 5 and 6 but on
SX48/42 devices, it is also necessary to set or clear bit 7 in order to switch between the upper and lower
banks. So instead of using the BANK instruction to switch between banks, use the _bank macro.
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.
The next example is a replacement for the MODE instruction:
; Sets the mode register appropriately for all types of SX controllers
;
_mode macro 1
IFDEF SX48_52
mov w, #\1
; loads the M register correctly for the SX48BD and
; SX52BD
mov m, w
ELSE
mov m, #\1
; loads the M register correctly for the SX20AC
; and SX28AC
ENDIF
endm
The MODE instruction has a four bit operand only which is sufficient for SX20/28 devices as they only
use four bits of the M register, however, the SX48/52 devices have the added ability of reading and
writing some of the port registers, and therefore use five bits in the M register. The MOV M, w
instruction modifies all bits of the M register, so this instruction must be used on the SX48/52 to make
sure that the M register is written with the correct value. So , instead of using the MODE or MOV M,
#<lit> instructions use _mode.
SX-Key/Blitz Development System Manual 2.0 • Parallax, Inc. • Page 67