Assembler : PC-Engine Library : MACRO.INC
'macro.inc' contains a set of macros for commonly-used
sequences of code
(such as
The 'map' macro :
Useful macro to map a ROM bank into addressable memory.
With this macro you don't need to remember in what bank
your data are stored, just use 'map label' to map the
bank where 'label' has been defined.
Example :
map my_data
. . .
.bank 4
.org $4000
my_data: .dw $0123,$4567,$89AB,$CDEF
|
This example will map bank 4, at address $4000.
16-bit pseudo instructions :
Several macros were defined to make
Here's a list of those macros (see directly in the include file for the exact syntax) :
| stw | - | store a value |
| addw | - | addition |
| adcw | - | addition with carry |
| subw | - | substraction |
| sbcw | - | substraction with carry |
| cmpw | - | comparison |
These macros accept two arguments, the first argument
is the source and can be either an immediate value
#4)label,$2500), and the second
argument is the destination, this last one can only be
a memory location.
The following macros accept only one argument, a memory location.
| stwz | - | store a zero value |
| incw | - | increment |
| decw | - | decrement |
| rolw | - | left rotation through carry flag |
| rorw | - | right rotation through carry flag |
| aslw | - | arithmetic shift-left |
| lsrw | - | logical shift-right |
| negw | - | negate (2's complement) |
Example :
inc_xpos:
stw x,tmp
incw tmp
cmpw #224,tmp
blo .l1
stw tmp,x
.l1:
rts
|
8-bit pseudo instructions :
There are three 8-bit pseudo instructions defined in 'macro.inc' :
| neg | - | negate the accumulator (2's complement) |
| add | - | same as the 'adc' instruction, but this macro takes care to reset the C flag before doing the addition |
| sub | - | same as 'sbc' but set the C flag prior to do the substraction |
Branch alias macros :
Rather than using 'bcc' and 'bcs' when checking the result
of a comparison, you can use these two macros instead :
blo
bhs
They mean respectively 'Branch if LOwer' and 'Branch if
Higher or Same'. They are more easy to remember than
'bcc' and bcs'. :)
Long branch macros :
The HuC6280 only supports 8-bit signed offsets in conditionnal branch instructions, in some cases that can be too short. The following macros can be used when a longer branch is needed :
lbne
lbeq
lbpl
lbmi
lbcc
lbcs
lblo
lbhs
Special macros :
Some macros have a second form; with an underscore that preecedes them. Those macros are the same as the macros without an underscore, the difference is these macros preserve the state of the registers they use (at the expense of speed).
Here's the list of these macros:
_stw
_addw
_adcw
_subw
_sbcw
_cmpw
_incw
_decw