aslfaqs
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| aslfaqs [2025/09/20 17:31] – [What is indirection and how do I use it?] reggie | aslfaqs [2025/09/23 17:33] (current) – [How do negative numbers work?] reggie | ||
|---|---|---|---|
| Line 537: | Line 537: | ||
| ==== What is indirection and how do I use it? ==== | ==== What is indirection and how do I use it? ==== | ||
| - | The standard way of accessing a variable in memory is via **direct extended** addressing. A 16-bit address is given, and an 8 or 16 bit operand is read from this ' | + | The standard way of accessing a variable in memory is via **direct extended** addressing. A 16-bit address is given, and an 8 or 16 bit operand is read from this ' |
| CURSPOS rmb 2 | CURSPOS rmb 2 | ||
| Line 651: | Line 651: | ||
| ==== How do negative numbers work? ==== | ==== How do negative numbers work? ==== | ||
| - | [Fill in later] | + | Think of an old-fashioned clock face as an analogy with an 8-bit register. An hour has 60 minutes, marked as 0 to 59. The minute hand goes only one way, and when it come round to zero the hour hand advances. |
| + | |||
| + | An 8-bit register has 256 values, marked as 0 to 255, and when it overflows round to zero the carry flag is set. | ||
| + | |||
| + | How do negative numbers work on a clock? It's entirely down to how we choose to read them. We can say " | ||
| + | |||
| + | In binary the principle works just the same, only (for an 8-bit value) we subtract from 256 instead of 60, ie. "minus ten" equals " | ||
| + | |||
| + | Which signed numbers are positive and which negative? Highest bit set means negative, so unsigned values 128 to 255 represent -128 to -1. Positive signed values range from 0 to 127. This is called " | ||
| + | |||
| + | This format is chosen because the underlying circuitry doesn' | ||
| + | |||
| + | Which instructions deal with signed numbers? There' | ||
| + | |||
| + | Signed branches | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | Miscellaneous instructions | ||
| + | |||
| + | NEG (8-bit only) | ||
| + | SEX Sign EXtend B to D | ||
| + | COMA; COMB; ADDD #1 negate D | ||
| + | |||
| + | Note that other than the simple BPL/BMI, the signed variants are not commonly used. If you do choose one, think twice whether you meant the unsigned variant. Signed comparisons should not be used with addresses for example. | ||
| + | |||
| + | |||
| + | |||
| ==== What do all the instructions do? ==== | ==== What do all the instructions do? ==== | ||
| [Will get round to this one] | [Will get round to this one] | ||
aslfaqs.1758389461.txt.gz · Last modified: 2025/09/20 17:31 by reggie
