;
; main routine: establish the stack, then read
; and write.
;
        lcw r1 stack        ; set up stack
        loa r3 r0           ; get variable

        lcw r2 increment    ; call increment
        cal r2 r2           ;

        sto r3 r0           ; write result,
        hlt                 ;    and halt

increment
        psh r2              ; save the return address on the stack
        add r3 r3 1         ; add 1 to the input parameter
        pop r2              ; get the return address from the stack back into r2
                            ; technically this wasn't required since we didn't change
                            ; r2, but it's a good habit to get into
        jmp r2              ; go back to where we were called from

;
; stack area: 50 words
;
        dat 100
stack
