aslfaqs
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
aslfaqs [2025/09/23 17:28] – [How do negative numbers work?] reggie | aslfaqs [2025/09/23 17:33] (current) – [How do negative numbers work?] reggie | ||
---|---|---|---|
Line 659: | Line 659: | ||
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 " | 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 " | + | 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' | This format is chosen because the underlying circuitry doesn' | ||
Line 665: | Line 665: | ||
Which instructions deal with signed numbers? There' | Which instructions deal with signed numbers? There' | ||
- | Signed branches | + | Signed branches |
| | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
Miscellaneous instructions | Miscellaneous instructions | ||
| | ||
- | NEG < | + | NEG (8-bit only) NEGate |
- | SEX < | + | SEX Sign EXtend B to D |
- | COMA; COMB; ADDD #1 (negate 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. | 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. |
aslfaqs.1758648511.txt.gz · Last modified: 2025/09/23 17:28 by reggie