\input texinfo  @c -*-texinfo-*-
@setfilename ../info/CCL
@settitle CCL -- Code Conversion Language

@titlepage
@sp 6
@center @titlefont{CCL -- Code Conversion Language}
@sp 4
@center Version 2.0
@sp 5
@center Ken'ichi HANDA
@center handa@@etl.go.jp
@page

@end titlepage

@node Top, , , (mule)
@chapter CCL --  Code Conversion Language

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

        BUFFER_MAGNIFICATION := integer
        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) | integer

        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 | integer | string])
                | (write-read-repeat REG [integer | 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 integer) | (write string) | string
                | (write REG ARRAY)
        END := (end)

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

MACHINE CODE:

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

OPERATER BIT FIELD (23-bit): XXXXXXXXXXXXXXX RRR TTTTT
        TTTTT (5-bit): operator type
        RRR (3-bit): resigter 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 !=

OPERATERS:      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
@end example

@contents
@bye
