word.inc

Summary
word.inc
Word-sized value manipulation macros.
stwzSet stated memory location to zero.
stwStore word-sized value at stated memory location.
adcwAdd word-sized value plus carry to value at stated memory location.
addwAdd word-sized value to value at stated memory location.
sbcwSubstract word-sized value plus carry from value at stated memory location.
subwSubstract word-sized value plus carry from value at stated memory location.
incwIncrement a word-sized value at stated memory location.
decwDecrement a word-sized value at stated memory location.
rolwLeft rotate word-sized value.
aslwLeft shift word-sized value.
rorwRight rotate word-sized value.
lsrwRight shift word-sized value.
negwNegate word-sized value.
phwPush word-sized value onto the stack.
plwPull word-sized value from the stack.

Word-sized value manipulation macros.

stwz

Set stated memory location to zero.

Assembly call

stwz op

Parameter

opOutput memory location

Restrictions

opAddressing modes must be either Zero Page or Absolute.

stw

Store word-sized value at stated memory location.

Assembly call

stw p0, p1

Parameters

p0Input data.
p1Output memory location.

Restrictions

p0Zero Page, Absolute or Immediate.
p1Zero Page or Absolute.

adcw

Add word-sized value plus carry to value at stated memory location.  Depending on the number of arguments, the addition is performed in place or the result is stored in the memory location specified in the third argument.

Assembly call

adcw p0, p1
adcw p0, p1, p2

Parameters

p0First operand.
p1Second operand.
p2(Optional) Output memory location.

Restrictions

p0Zero Page, Absolute or Immediate.
p1Zero Page, Absolute or Immediate if the 3rd argument is set.
p2Zero Page or Absolute

Examples

The following bits of code adds $cafe to the word-sized value stored in RAM at $2220 and $2221, and stores the result at the same memory location.

adcw #$cafe, $2200

This is equivalent in pseudo-code to:

$2200 += #$cafe

The next example adds 1234 and 5678 and stores the result into a word-sized value stored in zero page.

adcw #1234, #5678, <_out

The corresponding pseudo-code is:

<_out = #5678 + #1234

addw

Add word-sized value to value at stated memory location.

Description

This is equivalent to call the clc instruction followed by the adcw macro.

See Also

adcw

sbcw

Substract word-sized value plus carry from value at stated memory location.  Depending on the number of arguments, the substraction is performed in place or the result is stored in the memory location specified in the third argument.

Assembly call

sbcw p0, p1
sbcw p0, p1, p2

Parameters

p0First operand.
p1Second operand.
p2(Optional) Output memory location.

Restrictions

p0Zero Page, Absolute or Immediate.
p1Zero Page, Absolute or Immediate if the 3rd argument is set.
p2Zero Page or Absolute.

Examples

Substract $cafe to the word-sized value stored in RAM at $2220 and $2221, and stores the result at the same memory location.

sbcw #$cafe, $2200

Or to put it in pseudo-code:

$2200 -= #$cafe

Substract 1234 from 5678 and stores the result into a word-sized value stored in zero page.

sbcw #1234, #5678, <_out

Which givec in C pseudo-code:

<_out = #5678 - #1234

subw

Substract word-sized value plus carry from value at stated memory location.  This is equivalent to call the sec instruction followed by the sbcw macro.

See Also

sbcw

incw

Increment a word-sized value at stated memory location.

Assembly call

incw p0

Parameter

p0Memory location.

Restrictions

p0Zero Page or Absolute

decw

Decrement a word-sized value at stated memory location.

Assembly call

decw p0

Parameter

p0Memory location.

Restrictions

p0Zero Page or Absolute.

rolw

Left rotate word-sized value.

Assembly call

rolw p0

Parameter

p0Memory location.

Restrictions

p0Zero Page or Absolute.

aslw

Left shift word-sized value.

Assembly call

aslw p0

Parameter

p0Memory location.

Restrictions

p0Zero Page or Absolute.

rorw

Right rotate word-sized value.

Assembly call

rorw p0

Parameter

p0Memory location.

Restrictions

p0Zero Page or Absolute.

lsrw

Right shift word-sized value.

Assembly call

lsrw p0

Parameter

p0Memory location.

Restrictions

p0Zero Page or Absolute.

negw

Negate word-sized value.

Assembly call

negw p0

Parameter

p0Memory location.

Restrictions

p0Zero Page or Absolute.

phw

Push word-sized value onto the stack.

Assembly call

phw p0

Parameter

p0Value.

Restrictions

p0Zero Page, Absolute or Immediate.

plw

Pull word-sized value from the stack.

Assembly call

plw p0

Parameter

p0Value.

Restrictions

p0Zero Page or Absolute.
Add word-sized value plus carry to value at stated memory location.
Substract word-sized value plus carry from value at stated memory location.
Close