1 Assembly macros
NovaSquirrel edited this page 2016-08-09 22:38:29 -04:00

Legend: A means the A register is not preserved.

Swap macros

swapx A, B - Swap variable A with variable B. A X

swapy A, B - Swap variable A with variable B. A Y

swapa A, B - Swap variable A with variable B. A

swaparray List - Swap List,x and List,y. A

Directives

.nyb A, B - Like .byt but inserts a byte with A for the most significant nybble and B for the least significant one.

.raddr Address - Like .addr but inserts the given word minus 1, for RTS trick tables.

Synthetic instructions

add Number - Adds a number without carry. A

sub Number - Subtracts a number without carry. A

notcarry - Toggles carry.

asr - Arithmetic right shift. A

neg - Negate the accumulator. A

abs - Take the absolute value of the accumulator. A

countdown Variable - Decrements a variable if it's nonzero. A

unpack Low, High - Splits a byte into two nybbles, storing the least significant nybble in Low and the most significant nybble (after being shifted right) in High. A

unpackx Low, High and unpacky Low, High - Same, but indexed.

Synthetic instructions (16-bit helpers)

neg16 Low, High - Negates a 16-bit variable. A

neg16x Low, High - Same, but indexed by X. A

inc16 Variable - Increment a 16-bit variable.

sex - Sign extend. Change accumulator to $ff if negative, or $00 if positive.

addcarry High - Increments High if carry set. For adding 8-bit numbers to 16-bit ones.

addcarryx High - Same, but indexed by X.

subcarry High - Decrements High if carry unset. For subtracting 8-bit numbers from 16-bit ones.

subcarryx High - Same, but indexed by X.

I wish I had PHX and PLX

pushaxy, pullaxy, pushax, pullax, pushay, pullay

Long branch

jeq, jne, jpl, jmi, jcc, jcs

Conditional return

rtseq, rtsne, rtscc, rtscs

Miscellaneous

PositionXY Nametable, X, Y - Sets PPUADDR to a given X and Y coordinate for a specific Nametable. A