;Alto->8086 small-c compiler rev 2.0 C←CODE SEGMENT $INCLUDE(8086LIB.D) $INCLUDE(nrpcagent.DEC) ASSUME CS:C←CODE, DS:C←DATA ; #include <Env.h> ; extern int CallFailed; ; extern int ImportFailed; ; extern int *StartBonsai(); ; extern CallBonsai(); ; extern CleanupCall(); ; extern AllocWordsFromPkt(); ; extern StringToPkt(); ; extern Block(); ; extern Marshall(); ; extern MoveBlock(); ; extern Swab(); ; extern Zero(); ; extern CONT(); ; extern ENABLE(); ; extern struct ShortSTRING *CStringToString(); ; extern struct ImportInstance *ImportInterface(); ; extern struct VersionRange *matchAllVersions; ; static struct ImportInstance agentInstance[1]; ; static struct ShortSTRING *agentRope; ; int /* really Authentication */ ; AgentAuthenticate(nonceId, caller, callee, lvAuthenticator) ←AgentAuthenticate: ; int nonceId, caller, callee, *lvAuthenticator; PUSH BP MOV BP,SP PUSH CX PUSH BX ; { ; struct Seal sl; ; struct Seal1 csr; ; int *ap, *sp; ; int authentication; ; if (ENABLE(CallFailed, &CONT, &sl)) return (0); ADD SP,0FFF0X MOV BX,←CallFailed PUSH BX ;&←sl LEA BX,[BP-8] MOV CX,OFFSET ←CONT CALL ←ENABLE POP DX OR BX,BX JZ X1 XOR BX,BX MOV SP,BP POP BP RET; X1: ; sp = ap = StartBonsai(agentInstance, &csr); ;&←csr LEA BX,[BP-14] LEA CX,←agentInstance CALL ←StartBonsai ; ←ap ← BX MOV [BP-16],BX ; ←sp ← BX MOV [BP-18],BX ; *ap++ = Swab(doAuthenticate); /* procedure index */ ADD WORD PTR [BP-16],2 ; BX ← ←ap MOV BX,[BP-16] PUSH BX MOV BX,4 CALL ←Swab MOV CX,BX POP BX MOV [BX-2],CX ; if (nonceId) Marshall(true, ap, nonceId, 2); ; BX ← ←nonceId MOV BX,[BP+6] OR BX,BX JZ X2 MOV BX,0FFFFX PUSH BX ; BX ← ←ap MOV BX,[BP-16] PUSH BX MOV BX,2 ; CX ← ←nonceId MOV CX,[BP+6] CALL ←Marshall ADD SP,4 ; else Zero(ap, 2); JR X3 X2: MOV BX,2 ; CX ← ←ap MOV CX,[BP-16] CALL ←Zero X3: ; ap += 2; ADD WORD PTR [BP-16],4 ; ap = StringToPkt(ap, caller); ; BX ← ←caller MOV BX,[BP+4] ; CX ← ←ap MOV CX,[BP-16] CALL ←StringToPkt ; ←ap ← BX MOV [BP-16],BX ; ap = StringToPkt(ap, callee); ; BX ← ←callee MOV BX,[BP-2] ; CX ← ←ap MOV CX,[BP-16] CALL ←StringToPkt ; ←ap ← BX MOV [BP-16],BX ; CallBonsai(&csr, ap-sp); ; BX ← ←sp MOV BX,[BP-18] ; CX ← ←ap MOV CX,[BP-16] SUB CX,BX SHR CX MOV BX,CX ;&←csr LEA CX,[BP-14] CALL ←CallBonsai ; ap = sp; ; BX ← ←sp MOV BX,[BP-18] ; ←ap ← BX MOV [BP-16],BX ; authentication = AllocWordsFromPkt(&ap, false); XOR BX,BX ;&←ap LEA CX,[BP-16] CALL ←AllocWordsFromPkt ; ←authentication ← BX POP DX PUSH BX ; *lvAuthenticator = AllocWordsFromPkt(&ap, false); XOR BX,BX ;&←ap LEA CX,[BP-16] CALL ←AllocWordsFromPkt MOV CX,BX ; BX ← ←lvAuthenticator MOV BX,[BP-4] MOV [BX],CX ; CleanupCall(&csr); ;&←csr LEA BX,[BP-14] CALL ←CleanupCall ; return (authentication); ; BX ← ←authentication POP BX PUSH BX MOV SP,BP POP BP RET; ; }; ; int Vitae(clientMachine, range, interfaceType, lvclientRname, lvclientInstance, lvserverInstance) ←Vitae: ; int clientMachine; ; int *range; ; struct ShortSTRING *interfaceType; ; struct ShortSTRING **lvclientRname; ; struct ShortSTRING **lvclientInstance; ; struct ShortSTRING **lvserverInstance; PUSH BP MOV BP,SP PUSH CX PUSH BX ; { ; struct Seal sl; ; struct Seal1 csr; ; int serverMachine; ; int *ap, *sp; ; if (ENABLE(CallFailed, &CONT, &sl)) return (0); ADD SP,0FFF0X MOV BX,←CallFailed PUSH BX ;&←sl LEA BX,[BP-8] MOV CX,OFFSET ←CONT CALL ←ENABLE POP DX OR BX,BX JZ X4 XOR BX,BX MOV SP,BP POP BP RET; X4: ; sp = ap = StartBonsai(agentInstance, &csr); ;&←csr LEA BX,[BP-14] LEA CX,←agentInstance CALL ←StartBonsai ; ←ap ← BX MOV [BP-18],BX ; ←sp ← BX POP DX PUSH BX ; *ap++ = Swab(doVitae); /* procedure index */ ADD WORD PTR [BP-18],2 ; BX ← ←ap MOV BX,[BP-18] PUSH BX MOV BX,5 CALL ←Swab MOV CX,BX POP BX MOV [BX-2],CX ; *ap++ = clientMachine; /* byte pair really */ ADD WORD PTR [BP-18],2 ; BX ← ←ap MOV BX,[BP-18] ; CX ← ←clientMachine MOV CX,[BP+10] MOV [BX-2],CX ; if (range) Marshall(true, ap, range, 2); ; BX ← ←range MOV BX,[BP+8] OR BX,BX JZ X5 MOV BX,0FFFFX PUSH BX ; BX ← ←ap MOV BX,[BP-18] PUSH BX MOV BX,2 ; CX ← ←range MOV CX,[BP+8] CALL ←Marshall ADD SP,4 ; else Zero(ap, 2); JR X6 X5: MOV BX,2 ; CX ← ←ap MOV CX,[BP-18] CALL ←Zero X6: ; ap += 2; ADD WORD PTR [BP-18],4 ; ap = StringToPkt(ap, interfaceType); ; BX ← ←interfaceType MOV BX,[BP+6] ; CX ← ←ap MOV CX,[BP-18] CALL ←StringToPkt ; ←ap ← BX MOV [BP-18],BX ; CallBonsai(&csr, ap-sp); ; BX ← ←sp POP BX PUSH BX ; CX ← ←ap MOV CX,[BP-18] SUB CX,BX SHR CX MOV BX,CX ;&←csr LEA CX,[BP-14] CALL ←CallBonsai ; serverMachine = *sp++; ADD WORD PTR [BP-20],2 ; BX ← ←sp POP BX PUSH BX MOV CX,[BX-2] ; ←serverMachine ← CX MOV [BP-16],CX ; *lvclientRname = AllocStringFromPkt(&sp); ;&←sp LEA BX,[BP-20] CALL ←AllocStringFromPkt MOV CX,BX ; BX ← ←lvclientRname MOV BX,[BP+4] MOV [BX],CX ; *lvclientInstance = AllocStringFromPkt(&sp); ;&←sp LEA BX,[BP-20] CALL ←AllocStringFromPkt MOV CX,BX ; BX ← ←lvclientInstance MOV BX,[BP-2] MOV [BX],CX ; *lvserverInstance = AllocStringFromPkt(&sp); ;&←sp LEA BX,[BP-20] CALL ←AllocStringFromPkt MOV CX,BX ; BX ← ←lvserverInstance MOV BX,[BP-4] MOV [BX],CX ; CleanupCall(&csr); ;&←csr LEA BX,[BP-14] CALL ←CleanupCall ; return (serverMachine); ; BX ← ←serverMachine MOV BX,[BP-16] MOV SP,BP POP BP RET; ; }; ; int /*BOOL*/ AgentInitialize() ←AgentInitialize: PUSH BP MOV BP,SP ; { ; struct InterfaceName interface; ; struct Seal sl; ADD SP,0FFF4X ; Zero(&interface, lenInterfaceName); MOV BX,4 ;&←interface LEA CX,[BP-8] CALL ←Zero ; interface.type = agentRope; MOV BX,←agentRope ; ←interface ← BX MOV [BP-8],BX ; interface.instance = 0; MOV WORD PTR [BP-6],0 ; Move2(&interface.version, matchAllVersions); MOV BX,←matchAllVersions ;&←interface LEA CX,[BP-4] CALL ←Move2 ; if (ENABLE(ImportFailed, &CONT, &sl)) return (false); MOV BX,←ImportFailed PUSH BX ;&←sl LEA BX,[BP-12] MOV CX,OFFSET ←CONT CALL ←ENABLE POP DX OR BX,BX JZ X7 XOR BX,BX MOV SP,BP POP BP RET; X7: ; ImportInterface(0, &interface, agentInstance); XOR BX,BX PUSH BX LEA BX,←agentInstance ;&←interface LEA CX,[BP-8] CALL ←ImportInterface POP DX ; Block(); CALL ←Block ; return (true); MOV BX,0FFFFX MOV SP,BP POP BP RET; ; }; ; AgentRopes() ←AgentRopes: PUSH BP MOV BP,SP ; { ; agentRope = CStringToString("Agent.Lark"); MOV BX,"Agent.Lark" CALL ←CStringToString MOV ←agentRope,BX ; }; MOV SP,BP POP BP RET; ; Externals Declared Here PUBLIC ←AgentAuthenticate PUBLIC ←Vitae PUBLIC ←AgentInitialize PUBLIC ←AgentRopes C←CODE ENDS ; Number of Bytes of Code = 01FDX, (509)