<--  back   Last regenerated: 2022-04-20 17:31:36 kio

zasm - Z80 Assembler – Version 4.4

Assembler directives

#charset

#charset <name>
#charset none
#charset map <characterstring> = <firstcodepoint>
#charset unmap <characterstring>

zasm can translate characters from the source file (which must be ascii or utf-8) to the character Pseudo instructions: defl, set and '='
Labels: SET
set of the target system. Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
If no translation was Pseudo instructions: defl, set and '='
Labels: SET
set, then Latin-1 is assumed for your target system, which simply means: nothing is translated, the source is assumed to be utf-8 encoded and after utf-8 decoding the resulting characters must be in range 0x00 to 0xFF.

Translation should only be applied to printable characters, though it might be tempting to convert '\n' (10) to '\r' (13) for targets which use '\r' to start a new line.

zasm translates character literals like 'A' and strings like "foobar" into the selected character Pseudo instructions: defl, set and '='
Labels: SET
set. Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
If a translation is not available in the target character Pseudo instructions: defl, set and '='
Labels: SET
set, then zasm issues an error.

This translation is done everywhere: in pseudo opcodes like defm as well as in immediate arguments of opcodes or in the value for #if, Assembler directives: #code
Including C Source Files: #code
#code or Assembler directives: #data
Including C Source Files: #data
#data. It is not applied to filenames in Assembler directives: #include
Including C Source Files: #include
#include etc. or to the string in #charset itself.
Caveat: It is applied to the numeric value <firstcodepoint> in #charset, Assembler directives: #if, #elif, #else, #endif
Pseudo instructions: if, endif
if you use a character literal here.

    defm  "Say hello" + 0x80
    ld    a,'D'+1
    defb  0x20, 'a', '▞', '£'
Assembler directives: #assert
Pseudo instructions: #assert
#assert ' ' == 0 ; is the ZX80 / ZX81 character Pseudo instructions: defl, set and '='
Labels: SET
set selected?

This translation is also applied to strings in c sources: sdcc creates .ascii Pseudo instructions
8080 Assembler: 8080 pseudo instructions
pseudo instructions which are handled just like defm.
But unluckily sdcc emits only hexcode constants for character literals, and for this reason character literals in the c source will not be translated:

static const char foo[] = "My little secret";   // will be translated
char c = 'A';                                   // won't be translated :-(

Using character Pseudo instructions: defl, set and '='
Labels: SET
set translation is especially useful for targets with a character Pseudo instructions: defl, set and '='
Labels: SET
sets which is not based on ASCII, e.g. for the ZX81.

Available translations are:
  • zx80
  • zx80_inverted
  • zx81
  • zx81_inverted
  • zxspectrum
  • jupiterace
  • jupiterace_inverted
  • ascii
  • none

ZX80 and ZX81 have completely non-ascii character codes, even character code 0x00 is a legal character: the space. (caveat: this may lead to problems in c source.) There are no lowercase letters. Instead lower case letters are used as an easy way to create an inverted (uppercase) letter.

ZX Spectrum and Jupiter Ace have a character Pseudo instructions: defl, set and '='
Labels: SET
set which is mostly ascii, but with '©' and '£' added.

They all have block graphics symbols, e.g. these characters can be used in a source file for the ZX Spectrum: "©£ ▝▘▀▗▐▚▜▖▞▌▛▄▟▙█". (note: the ' ' in the string is the non-breaking space.)

ASCII limits available characters to the 7-bit ascii range.

NONE resets the character translation. (effectively to Latin-1, see above.)

The inverted character Pseudo instructions: defl, set and '='
Labels: SET
sets produce characters with bit 7 toggled (bit 7 indicates inversion in all character Pseudo instructions: defl, set and '='
Labels: SET
sets) compared to the not-inversed character Pseudo instructions: defl, set and '='
Labels: SET
set. As the block graphics already consist of inverted and not inverted characters, the inverted characters are reverted to normal in the inverted character Pseudo instructions: defl, set and '='
Labels: SET
sets.

It is possible to enable, redefine and disable the character Pseudo instructions: defl, set and '='
Labels: SET
set throughout the source whenever and as often as required.

Custom character sets

You can construct your own translation table starting from any predefined translation or from scratch:

#charset ascii
#charset map "abcdefghijklmnopqrstuvwxyz" = 'A'
#charset unmap "`{|}~"

In this #insert: Examples:
#assert: Example:
incbin: Examples:
#assert: Example:
example we limit the range of available characters to uppercase characters, e.g. for a veerry oolld printer:

We start with the ASCII character Pseudo instructions: defl, set and '='
Labels: SET
set and map all lowercase characters to their uppercase counterparts and remove all special characters in the lowercase characters vicinity. The resulting characters are now limited to the range 0x20 to 0x5F. Characters 0x60 to 0x7E are either remapped or disabled. Character 0x7F was no ascii character from the start.

Now all uppercase and lowercase characters in character literals and strings in your source are translated to uppercase ASCII characters and any use of '`' to '~' will result in an error.

Valid HTML   Valid CSS