word.inc | |
Word-sized value manipulation macros. | |
stwz | Set stated memory location to zero. |
stw | Store word-sized value at stated memory location. |
adcw | Add word-sized value plus carry to value at stated memory location. |
addw | Add word-sized value to value at stated memory location. |
sbcw | Substract word-sized value plus carry from value at stated memory location. |
subw | Substract word-sized value plus carry from value at stated memory location. |
incw | Increment a word-sized value at stated memory location. |
decw | Decrement a word-sized value at stated memory location. |
rolw | Left rotate word-sized value. |
aslw | Left shift word-sized value. |
rorw | Right rotate word-sized value. |
lsrw | Right shift word-sized value. |
negw | Negate word-sized value. |
phw | Push word-sized value onto the stack. |
plw | Pull word-sized value from the stack. |
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.
adcw p0, p1 adcw p0, p1, p2
p0 | First operand. |
p1 | Second operand. |
p2 | (Optional) Output memory location. |
p0 | Zero Page, Absolute or Immediate. |
p1 | Zero Page, Absolute or Immediate if the 3rd argument is set. |
p2 | Zero Page or Absolute |
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
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.
sbcw p0, p1 sbcw p0, p1, p2
p0 | First operand. |
p1 | Second operand. |
p2 | (Optional) Output memory location. |
p0 | Zero Page, Absolute or Immediate. |
p1 | Zero Page, Absolute or Immediate if the 3rd argument is set. |
p2 | Zero Page or Absolute. |
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