        $MACRO all VAR
        JSR PC,$$RES
        RES.STR #@{1} @#$$RES1
        $ENDM
;
        $MACRO fre
        MOV (SP),R0
        ADD R0,SP
        $ENDM
        $MACRO RES.STR ;  NAME,SIZE
        SUB #@2,SP
        SUB #10.,SP
        MOV #1,-(SP)
        MOV #@2,-(SP)
        ADD #8.,(SP)
        MOV SP,#@1
        MOV #@1,-(SP)
        JSR PC,INI
        ADD #6.,(SP)
        JSR PC,$$$STK
        $ENDM
/
        PROGRAM LET
        setlab lt.
        optimize with r2
x1:     .asciz 'I%ERR <let #@1 = xxx op #@1 not supported>'
x2:     .asciz 'I%ERR <Too many operators LET #@1 = ... #@E #@F>'
x3:     .asciz 'M%OV #@{1},#@{3}'
x4:     .asciz 'LET #@1 = #@1 <#@*(6"D)>'
x5:     .asciz 'I%ERR <invalid Let op: #@4>'
y1:     .asciz '$%% ADD* #@{1},#@{5}'
y2:     .asciz '$%% SUB* #@{1},#@{5}'
y3:     .asciz '$%% MUL45 #@{1},#@{5}'
y4:     .asciz '$%% DIV45 #@{1},#@{5}'
        .even

;-
; let statement - hardcoded.  part 1 handles error
; checking and arithmetic operators.
;
;+
        AUTO pm
FUNCTION lett[s,t,n,lab]
        IF lab LT #0
            mov #2,pm(r5)
        ELSE
            mov #1,pm(r5)
        FI
        LET r4 = cmpstr[t,<pm + #1>,t,<pm + #5>]
        IF r4 = #0
            . exstat[#x1,&s,#0]
            jmp done
        FI
        IF n GT #13.
            . exstat[#x2,&s,#0]
            jmp done
        FI
        LET r0 = cmpstr[t,<pm + #1>,t,<pm + #3>]
        IF r0 NE #0	;dif
            . let1[#x3,s,t,n,lab]
        FI
        LET r4 = pm + #4
        IF n GT r4
            LET r4 = fndstr[t,<pm + #4>]	+ #1 ;addr of op string
            SELECT caseb (r4)
            CASEB #'+
                mov #y1,r1
                BREAK
            CASEB #'-
                mov #y2,r1
                BREAK
            CASEB #'*
                mov #y3,r1
                BREAK
            CASEB #'/
                mov #y4,r1
                BREAK
            DEFAULT
                . exstat[#x5,&s,#0]
                jmp done
            ESAC
;        . exstat[r1,&s,#0]
            . let2[r1,s,t,n,lab]
        FI
        LET r4 = fndstr[t,<pm + #6>]
        IFB (r4) NE #0
            . exstat[#x4,&s,#0]
        FI
done:
        RET

;-
; exstat - expand S ("string") into p (mp string set)
; and run through statement processor (recurs)
;
;+
FUNCTION exstat[s,p,t]
        IF t = #0
            all r4
        ELSE
            LET r4 = t
        FI
        . expand[s,r4,p]
        . state[r4]
        IF t = #0
            fre
        FI
        RET

        .end
