.title emt -- emt executor for c programmed request routines ; emt 375 calls -- called from c by: ; _e75_[nv](emtcode,chan,arg1,[,...,argN]); .e75.v:: mov (pc)+, -(sp) ; set "return value" flag .e75.n:: clr -(sp) ; clear "return value" flag mov sp, r0 ; fetch pointer add #6, r0 ; to emt block movb -2(r0), 1(r0) ; combine emt code with channel emt 375 ; do it br .e.fin ; go finish up ; emt 374 calls -- called from c by: ; _e74_[nv](emtcode,chan); .e74.v:: mov (pc)+, -(sp) ; set "return value" flag .e74.n:: clr -(sp) ; clear "return value" flag mov 4(sp), r0 ; get the emt code swab r0 ; put in high byte bisb 6(sp), r0 ; get the channel emt 374 ; do it br .e.fin ; go finish up ; other emt calls -- called from c by: ; _exx_[nv](emtcode,r0arg,argcount[,arg1,...,argn]); .exx.v:: mov (pc)+, -(sp) ; set "return value" flag .exx.n:: clr -(sp) ; clear "return value" flag mov sp, r1 ; save stack pointer contents mov r2, -(sp) ; save r2 mov r1, r2 ; get another copy of stack frame pointer add #8., r2 ; point to count value mov (r2)+, r0 ; get it beq 2$ ; if no stack arguments, skip around 1$: mov (r2)+, -(sp) ; push an argument dec r0 ; loop until bne 1$ ; done 2$: mov r1, r2 ; get stack frame pointer again cmp (r2)+, (r2)+ ; bump to point to emt value bis #emt, (r2)+ ; make it an emt instruction mov (r2), r0 ; get r0 value mov #137, (r2)+ ; return to proper place after mov #3$, (r2) ; executing emt instruction jmp 2(r1) ; go execute the emt 3$: mov -2(r1), r2 ; restore r2 mov r1, sp ; restore sp ; br .e.fin ; go finish up ; [fall through to .e.fin] .e.fin: bcs .e.err ; if error, go return error code tst (sp)+ ; return value? bne 1$ ; if so, go return it clr r0 ; otherwise, return zero 1$: return .e.err: tst (sp)+ ; clean up stack clr r0 ; clear r0 bisb @#52, r0 ; get the error byte com r0 ; return negative value return .end