z80:Directives:ASCIIMAP

From Learn @ Cemetech
Jump to navigationJump to search

Defines an ASCII mapping table. In English, this is a special table that can be used to translate strings from the ASCII you're dealing with on your PC to any special variations on the theme on the Z80 device you are assembling to. For example, the TI-83 Plus calculator has a θ symbol where the '[' is normally. Using an ASCII mapping table, you could automatically make any strings defined using the .asc directive handle this oddity. Another possibility would be a font where A-Z is actually 0-25 rather than the usual 65-90.

Syntax

   .asciimap start, [end], rule

Allowed inputs

The first two arguments define the range of characters you are translating, inclusive. You can miss out the second one if you are only redefining a single character. The final argument is a special rule telling Brass how to perform the translation. It is a standard expression, where the special code {*} specifies the current character being translated. Here are a couple of examples:

   .asciimap 'a', 'z', {*}+('A'-'a')   ; Force all strings UPPERCASE
   .asciimap $00, $FF, {*}             ; Reset to standard mapping
   .asciimap ' ', '_'                  ; Turn spaces into underscores
   .asciimap 'A', 'Z', {*}+1           ; Make each letter in the range A⇒Z one bigger (A→B, B→C &c)
   .asciimap 128, 255, {*}&%01111111   ; Clear the most significant bit (limit to 7-bit ASCII).

Uses

See Also