Numbers are held internally by the assembler as 32 bit 2's complement binary integers.Within the assembler source code, numbers begin with any of the characters 0 to 9, the $ character or the 0x character pair.
The assembler deals with all numbers internally as 32 bit integers. The numbers are only truncated when code or data is emitted. It is therefor possible to evaluate expressions that require greater than 16 bits of precission even though the asembler is targeted at an 8 bit processor.
e.g. fred .db (105 * 100000) / (10000 + 90000) ; will generate 105 at location fredNumbers that are enclosed in quotes are not considered as numbers by the assembler, but are instead considered as STRINGS. Strings can be interpreted as numbers by the assembler if explicitly coersed to numbers, but numbers within strings are considered different to normal numbers.
e.g. 123 is not the same as "123" 0+123 is considered the same as 0+"123" 0+123 is not the same as "0"+"123"Numbers can be specified in any of the radixes:
base 10(decimal) ,
base 16(hexadecimal)
base 8(octal) .
Octal NumbersDecimal numbers are made up of unbroken sequences of the characters 0 to 9. The first character of a decimal number must not be the character 0.
Numbers that begin with the character 0 are deemed to be OCTAL numbers NOT DECIMAL numbers
(NOTE: 0 on its own may be considered a decimal number by the programmer since 0 in decimal is equivalent to 0 in octal).
e.g. 510 ; this is equivalent to hex 1FE 1.25 ; this is an invalid number since the '.' character ; is not recognised as a valid part of a number ; the assembler only knows about integers and not reals 1,000,000 ; this is an invalid number since the ',' character ; is not recognised as a valid part of a number 1 000 000 ; this is an invalid number since the ' ' character ; is not a recognised as a valid part of a number 0123 ; this is recognised as an octal number not a decimal ; number. It is equivalent to the decimal number 83
Hexadecimal NumbersOctal numbers are made up of unbroken sequences of the characters 0 to 7. The first character of an octal number must be the character 0. Compare this with decimal numbers that cannot begin with the character 0
e.g. 0510 ; this is equivalent to hex 14A 510 ; this is an invalid octal number since it does not ; begin with a 0, the assembler interprets this ; as the decimal number 510
Invalid NumbersHexadecimal numbers are made up of unbroken sequences of the characters 0 to 9 and A to F. The first character of a hexadecimal number must be the character $ or the character pair 0x.
e.g. $0510 ; this is equivalent to decimal number 1298 0x510 ; this is equivalent to decimal number 1298 $ 510 ; this is an invalid hex number since there ; is a break between the $ and the remainder ; of the number. The assembler interprets this ; as the symbol $ followed by the decimal ; number 510NOTE:
The $ character can indicate a hex number or the location counter. If the $ character is immediately followed by a valid hex digit then the assembler interprets it as part of a hex number, otherwise as the location counter.
If a character outside of the normal character set for the radix being used forms part of the number, then the number will be terminated at the invalid character and the assembler will take the invalid character as the start of the next symbol
e.g. 0123456789 ; this number is treated as the octal number 01234567 ; followed by the decimal number 89 $0123ABH23 ; this number is treated as the hex number 0123AB ; followed by the symbol H23 123ABH23 ; this number is treated as the decimal number 123 ; followed by the symbol ABH23Decimal points, comma seperators and space seperators are not allowed for numbers of any radix.
e.g. 2.3 ; this number is treated as the number 2 followed by the ; symbol '.' followed by the number 3 1,234,567 ; this number is treated as the number 1 followed by the ; number 234 followed by the number 567 1 234 567 ; this number is treated as the number 1 followed by the ; number 234 followed by the number 567