Previous: , Up: MULE Character Sets and Encodings   [Contents][Index]


18.4 CCL

CCL PROGRAM SYNTAX:
     CCL_PROGRAM := (CCL_MAIN_BLOCK
                     [ CCL_EOF_BLOCK ])

     CCL_MAIN_BLOCK := CCL_BLOCK
     CCL_EOF_BLOCK := CCL_BLOCK

     CCL_BLOCK := STATEMENT | (STATEMENT [STATEMENT ...])
     STATEMENT :=
             SET | IF | BRANCH | LOOP | REPEAT | BREAK
             | READ | WRITE

     SET := (REG = EXPRESSION) | (REG SELF_OP EXPRESSION)
            | INT-OR-CHAR

     EXPRESSION := ARG | (EXPRESSION OP ARG)

     IF := (if EXPRESSION CCL_BLOCK CCL_BLOCK)
     BRANCH := (branch EXPRESSION CCL_BLOCK [CCL_BLOCK ...])
     LOOP := (loop STATEMENT [STATEMENT ...])
     BREAK := (break)
     REPEAT := (repeat)
             | (write-repeat [REG | INT-OR-CHAR | string])
             | (write-read-repeat REG [INT-OR-CHAR | string | ARRAY]?)
     READ := (read REG) | (read REG REG)
             | (read-if REG ARITH_OP ARG CCL_BLOCK CCL_BLOCK)
             | (read-branch REG CCL_BLOCK [CCL_BLOCK ...])
     WRITE := (write REG) | (write REG REG)
             | (write INT-OR-CHAR) | (write STRING) | STRING
             | (write REG ARRAY)
     END := (end)

     REG := r0 | r1 | r2 | r3 | r4 | r5 | r6 | r7
     ARG := REG | INT-OR-CHAR
     OP :=   + | - | * | / | % | & | '|' | ^ | << | >> | <8 | >8 | //
             | < | > | == | <= | >= | !=
     SELF_OP :=
             += | -= | *= | /= | %= | &= | '|=' | ^= | <<= | >>=
     ARRAY := '[' INT-OR-CHAR ... ']'
     INT-OR-CHAR := INT | CHAR

MACHINE CODE:

The machine code consists of a vector of 32-bit words.
The first such word specifies the start of the EOF section of the code;
this is the code executed to handle any stuff that needs to be done
(e.g. designating back to ASCII and left-to-right mode) after all
other encoded/decoded data has been written out.  This is not used for
charset CCL programs.

REGISTER: 0..7  -- referred by RRR or rrr

OPERATOR BIT FIELD (27-bit): XXXXXXXXXXXXXXX RRR TTTTT
        TTTTT (5-bit): operator type
        RRR (3-bit): register number
        XXXXXXXXXXXXXXXX (15-bit):
                CCCCCCCCCCCCCCC: constant or address
                000000000000rrr: register number

AAAA:   00000 +
        00001 -
        00010 *
        00011 /
        00100 %
        00101 &
        00110 |
        00111 ~

        01000 <<
        01001 >>
        01010 <8
        01011 >8
        01100 //
        01101 not used
        01110 not used
        01111 not used

        10000 <
        10001 >
        10010 ==
        10011 <=
        10100 >=
        10101 !=

OPERATORS:      TTTTT RRR XX..

SetCS:          00000 RRR C...C      RRR = C...C
SetCL:          00001 RRR .....      RRR = c...c
                c.............c
SetR:           00010 RRR ..rrr      RRR = rrr
SetA:           00011 RRR ..rrr      RRR = array[rrr]
                C.............C      size of array = C...C
                c.............c      contents = c...c

Jump:           00100 000 c...c      jump to c...c
JumpCond:       00101 RRR c...c      if (!RRR) jump to c...c
WriteJump:      00110 RRR c...c      Write1 RRR, jump to c...c
WriteReadJump:  00111 RRR c...c      Write1, Read1 RRR, jump to c...c
WriteCJump:     01000 000 c...c      Write1 C...C, jump to c...c
                C...C
WriteCReadJump: 01001 RRR c...c      Write1 C...C, Read1 RRR,
                C.............C      and jump to c...c
WriteSJump:     01010 000 c...c      WriteS, jump to c...c
                C.............C
                S.............S
                ...
WriteSReadJump: 01011 RRR c...c      WriteS, Read1 RRR, jump to c...c
                C.............C
                S.............S
                ...
WriteAReadJump: 01100 RRR c...c      WriteA, Read1 RRR, jump to c...c
                C.............C      size of array = C...C
                c.............c      contents = c...c
                ...
Branch:         01101 RRR C...C      if (RRR >= 0 && RRR < C..)
                c.............c      branch to (RRR+1)th address
Read1:          01110 RRR ...        read 1-byte to RRR
Read2:          01111 RRR ..rrr      read 2-byte to RRR and rrr
ReadBranch:     10000 RRR C...C      Read1 and Branch
                c.............c
                ...
Write1:         10001 RRR .....      write 1-byte RRR
Write2:         10010 RRR ..rrr      write 2-byte RRR and rrr
WriteC:         10011 000 .....      write 1-char C...CC
                C.............C
WriteS:         10100 000 .....      write C..-byte of string
                C.............C
                S.............S
                ...
WriteA:         10101 RRR .....      write array[RRR]
                C.............C      size of array = C...C
                c.............c      contents = c...c
                ...
End:            10110 000 .....      terminate the execution

SetSelfCS:      10111 RRR C...C      RRR AAAAA= C...C
                ..........AAAAA
SetSelfCL:      11000 RRR .....      RRR AAAAA= c...c
                c.............c
                ..........AAAAA
SetSelfR:       11001 RRR ..Rrr      RRR AAAAA= rrr
                ..........AAAAA
SetExprCL:      11010 RRR ..Rrr      RRR = rrr AAAAA c...c
                c.............c
                ..........AAAAA
SetExprR:       11011 RRR ..rrr      RRR = rrr AAAAA Rrr
                ............Rrr
                ..........AAAAA
JumpCondC:      11100 RRR c...c      if !(RRR AAAAA C..) jump to c...c
                C.............C
                ..........AAAAA
JumpCondR:      11101 RRR c...c      if !(RRR AAAAA rrr) jump to c...c
                ............rrr
                ..........AAAAA
ReadJumpCondC:  11110 RRR c...c      Read1 and JumpCondC
                C.............C
                ..........AAAAA
ReadJumpCondR:  11111 RRR c...c      Read1 and JumpCondR
                ............rrr
                ..........AAAAA

Previous: , Up: MULE Character Sets and Encodings   [Contents][Index]