//    TRN6


GET "TRNHDR"

LET COMPLAB(L) BE OUT2P(S.LAB, L)

AND COMPENTRY(N, L) BE
    $(  LET S = @N!2
        OUT3P(S.ENTRY, GETBYTE(S, 0), L)
        FOR I = 1 TO GETBYTE(S, 0) DO OUTC(GETBYTE(S, I))
        WRC('*S')  $)

AND COMPDATALAB(L) BE OUT2P(S.DATALAB, L)

AND COMPJUMP(L) BE OUT2P(S.JUMP, L)

AND OUTN1(X) BE
    $( WRN(X); WRC('*S') $)

AND OUT1(X) BE
    $( WRITEOP(X); WRC('*S')  $)

AND OUT2(X, Y) BE
    $( WRITEOP(X); WRC('*S')
       WRN(Y); WRC('*S')   $)

AND OUT2P(X, Y) BE
    $( WRITEOP(X); WRC('*S'); WRC('L')
       WRN(Y); WRC('*S')   $)

AND OUT3P(X, Y, Z) BE
    $( WRITEOP(X); WRC('*S')
       WRN(Y); WRC('*S'); WRC('L')
       WRN(Z); WRC('*S')   $)


AND OUTN(N) BE WRN(N)

AND OUTL(X) BE
    $( WRC('*S'); WRC('L'); WRN(X); WRC('*S')  $)

AND OUTC(X) BE
    $( WRN(CHARCODE(X)); WRC('*S')   $)

AND WRITEOP(X) BE
    TEST OPTION!6 THEN WRN(X)   // produce numeric ocode
    OR
    $(1 LET S = VALOF SWITCHON X INTO
        $( DEFAULT: TRANSREPORT(199, CURRENTBRANCH)
                    RESULTIS 'ERROR'

           CASE S.MULT:    RESULTIS "MULT"
           CASE S.DIV:     RESULTIS "DIV"
           CASE S.REM:     RESULTIS "REM"
           CASE S.PLUS:    RESULTIS "PLUS"
           CASE S.MINUS:   RESULTIS "MINUS"
           CASE S.EQ:      RESULTIS "EQ"
           CASE S.NE:      RESULTIS "NE"
           CASE S.LS:      RESULTIS "LS"
           CASE S.GR:      RESULTIS "GR"
           CASE S.LE:      RESULTIS "LE"
           CASE S.GE:      RESULTIS "GE"
           CASE S.LSHIFT:  RESULTIS "LSHIFT"
           CASE S.RSHIFT:  RESULTIS "RSHIFT"
           CASE S.LOGAND:  RESULTIS "LOGAND"
           CASE S.LOGOR:   RESULTIS "LOGOR"
           CASE S.EQV:     RESULTIS "EQV"
           CASE S.NEQV:    RESULTIS "NEQV"

           CASE S.NEG:     RESULTIS "NEG"
           CASE S.NOT:     RESULTIS "NOT"
           CASE S.ABS:     RESULTIS "ABS"
           CASE S.RV:      RESULTIS "RV"

           CASE S.TRUE:    RESULTIS "TRUE"
           CASE S.FALSE:   RESULTIS "FALSE"
           CASE S.QUERY:   RESULTIS "QUERY"

           CASE S.LP:      RESULTIS "LP"
           CASE S.LG:      RESULTIS "LG"
           CASE S.LN:      RESULTIS "LN"
           CASE S.LSTR:    RESULTIS "LSTR"
           CASE S.LL:      RESULTIS "LL"

           CASE S.LLP:     RESULTIS "LLP"
           CASE S.LLG:     RESULTIS "LLG"
           CASE S.LLL:     RESULTIS "LLL"

           CASE S.SP:      RESULTIS "SP"
           CASE S.SG:      RESULTIS "SG"
           CASE S.SL:      RESULTIS "SL"
           CASE S.STIND:   RESULTIS "STIND"

           CASE S.GETBYTE: RESULTIS "GETBYTE"
           CASE S.PUTBYTE: RESULTIS "PUTBYTE"

           CASE S.JUMP:    RESULTIS "JUMP"
           CASE S.JT:      RESULTIS "JT"
           CASE S.JF:      RESULTIS "JF"
           CASE S.GOTO:    RESULTIS "GOTO"
           CASE S.LAB:     RESULTIS "LAB"
           CASE S.STACK:   RESULTIS "STACK"
           CASE S.STORE:   RESULTIS "STORE"

           CASE S.ENTRY:   RESULTIS "ENTRY"
           CASE S.SAVE:    RESULTIS "SAVE"
           CASE S.FNAP:    RESULTIS "FNAP"
           CASE S.FNRN:    RESULTIS "FNRN"
           CASE S.RTAP:    RESULTIS "RTAP"
           CASE S.RTRN:    RESULTIS "RTRN"
           CASE S.ENDPROC: RESULTIS "ENDPROC"
           CASE S.RES:     RESULTIS "RES"
           CASE S.RSTACK:  RESULTIS "RSTACK"
           CASE S.FINISH:  RESULTIS "FINISH"

           CASE S.NEEDS:   RESULTIS "NEEDS"
           CASE S.SECTION: RESULTIS "SECTION"


           CASE S.SWITCHON:RESULTIS "SWITCHON"
           CASE S.GLOBAL:  RESULTIS "GLOBAL"
           CASE S.DATALAB: RESULTIS "DATALAB"
           CASE S.ITEML:   RESULTIS "ITEML"
           CASE S.ITEMN:   RESULTIS "ITEMN"   $)

        FOR I = 1 TO GETBYTE(S, 0) DO WRC(GETBYTE(S, I))   $)1


AND WRN(N) BE $( IF N<0 DO $( WRC('-'); N := - N  $)
                 WRPN(N)  $)

AND WRPN(N) BE $( IF N>9 DO WRPN(N/10)
                  WRC(N REM 10 + '0')  $)

AND ENDOCODE() BE $( WRCH('*N'); OCOUNT := 0  $)


AND WRC(CH) BE $( OCOUNT := OCOUNT + 1
                  IF OCOUNT>62 LOGAND CH='*S' DO
                            $( WRCH('*N'); OCOUNT := 0; RETURN  $)
                  WRCH(CH)  $)

.