BASE - Set number base

Syntax
  BASE <n>
  
  
Synonym

None

Description

The directive sets the default number base for constants to <n>. The operand <n> may be prefixed to indicate its number base; otherwise, the operand is considered to be in the current default base. Valid values of <n> are 2, 8, 10, 16. Unless a default base is specified using the BASE directive, the default number base is decimal.

Example

See the following listing, for examples of setting the number base.

Listing: Setting the number base

    4    4                    base    10   ; default base: decimal
    5    5   000000 64        dc.b    100

    6    6                    base    16   ; default base: hex

    7    7   000001 0A        dc.b    0a

    8    8                    base    2    ; default base: binary

    9    9   000002 04        dc.b    100

   10   10   000003 04        dc.b    %100

   11   11                    base    @12  ; default base: decimal

   12   12   000004 64        dc.b    100

   13   13                    base    $a   ; default base: decimal

   14   14   000005 64        dc.b    100

   15   15

   16   16                    base    8    ; default base: octal

   17   17   000006 40        dc.b    100

Be careful. Even if the base value is set to 16, hexadecimal constants terminated by a D must be prefixed by the $ character, otherwise they are supposed to be decimal constants in old style format. For example, constant 45D is interpreted as decimal constant 45, not as hexadecimal constant 45D.