Next: , Previous: Input-output operators, Up: MIX instruction set


2.1.2.9 Conversion operators

The following instructions convert between numerical values and their character representations.

NUM
Convert rAX, assumed to contain a character representation of a number, to its numerical value and store it in rA. OPCODE = 5, MOD = 0.
CHAR
Convert the number stored in rA to a character representation and store it in rAX. OPCODE = 5, MOD = 1.
Digits are represented in MIX by the range of values 30-39 (digits 0-9). Thus, if the contents of `rA' and `rX' are, for instance,
     [rA] = + 30 30 31 32 33
     [rX] = + 31 35 39 30 34

the represented number is 0012315904, and `NUM' will store this value in `rA' (i.e., we end up with `[rA]' = + 0 46 62 52 0 = 12315904).

If any byte in `rA' or `rB' does not belong to the range 30-39, it is interpreted by `NUM' as the digit obtained by taking its value modulo 10. E.g. values 0, 10, 20, 30, 40, 50, 60 all represent the digit 0; 2, 12, 22, etc. represent the digit 2, and so on. For instance, the number 0012315904 mentioned above could also be represented as

     [rA] = + 10 40 31 52 23
     [rX] = + 11 35 49 20 54

`CHAR' performs the inverse operation, using only the values 30 to 39 for representing digits 0-9.