;Alto->8086 small-c compiler rev 2.0 C_CODE SEGMENT $INCLUDE(8086LIB.D) $INCLUDE(larkmoneload.DEC) ASSUME CS:C_CODE, DS:C_DATA ; #include ; struct Core { ; int advice, addrlo, addrhi, count; ; char data[1]; ; }; ; extern SingleStep(); ; extern GoNormal(); ; extern GoFromBreak(); ; extern int mState[1]; ; extern int advice; ; extern MoveBlock(); ; extern ByteBlt(); ; extern Swab(); ; extern DoubleEQ(); ; extern SLCReset(); ; extern SStartRx(); ; extern struct PBI *SCheckRx(); ; extern SStartTx(); ; extern int SCheckTx(); /* BOOL */ ; static int elBuf[130]; ; static struct PBI elPBI; ; static int tlID[2]; ; static int stateTimer; ; static int stateInterval; ; static int gotReply; ; extern int tlNet; ; extern int tlHost; ; extern int tlImHost; ; extern int localNet; ; StartEL() _StartEL: PUSH BP MOV BP,SP ; { ; SLCReset(); CALL _SLCReset ; elPBI.pup = (struct Pup *) &elBuf[2]; LEA BX,_elBuf+4 MOV WORD PTR _elPBI+6,BX ; tlID[0] = tlID[1] = 0x6767; MOV _tlID+2,06767X MOV _tlID,06767X ; SStartRx(&elPBI, 256); MOV BX,0100X LEA CX,_elPBI CALL _SStartRx ; }; MOV SP,BP POP BP RET; ; CheckEL() _CheckEL: PUSH BP MOV BP,SP ; { ; if (SCheckRx() == 0) return; CALL _SCheckRx OR BX,BX JNZ X1 MOV SP,BP POP BP RET; X1: ; ELoadProc(&elPBI); LEA BX,_elPBI CALL _ELoadProc ; SStartRx(&elPBI, 256); MOV BX,0100X LEA CX,_elPBI CALL _SStartRx ; }; MOV SP,BP POP BP RET; ; static ELoadProc(pbi) _ELoadProc: ; struct PBI *pbi; PUSH BP MOV BP,SP PUSH BX ; { ; struct Pup *pup; ; char *caddr; ; char *cdata; ; int cAdvice; ; int ccount; ; int pupType; ; int maxLength; ; int dHost; ; struct Core *core; ADD SP,0FFEEX ; pup = pbi->pup; ; BX _ _pbi MOV BX,[BP-2] MOV CX,[BX+6] ; _pup _ CX MOV [BP-4],CX ; if (pup->dPort.socket.LS != 0) goto reject; ; BX _ _pup MOV BX,[BP-4] MOV CX,[BX+10] OR CX,CX JZ X2 JMP _reject X2: ; if (pup->dPort.socket.ms != 0x3000) goto reject; ; BX _ _pup MOV BX,[BP-4] MOV CX,[BX+12] MOV BX,CX CMP BX,03000X JZ X3 JMP _reject X3: ; dHost = pup->dPort.host; ; BX _ _pup MOV BX,[BP-4] MOV AL,[BX+9] XOR AH,AH ; _dHost _ AX MOV [BP-18],AX ; if ((dHost != EtherHost()) && (dHost != 0)) goto reject; CALL _EtherHost ; CX _ _dHost MOV CX,[BP-18] CMP CX,BX JZ X5 ; BX _ _dHost MOV BX,[BP-18] OR BX,BX X5: JZ X4 JMP _reject X4: ; if (!CheckCheckSum(pup)) goto reject; ; BX _ _pup MOV BX,[BP-4] CALL _CheckCheckSum OR BX,BX JNZ X6 JMP _reject X6: ; core = (struct Core *) &pup->data; ; BX _ _pup MOV BX,[BP-4] ADD BX,014X ; _core _ BX POP DX PUSH BX ; if (core->addrhi) goto reject; ; BX _ _core POP BX PUSH BX MOV CX,[BX+4] OR CX,CX JZ X7 JMP _reject X7: ; ccount = Swab(core->count); ; BX _ _core POP BX PUSH BX MOV CX,[BX+6] MOV BX,CX CALL _Swab ; _ccount _ BX MOV [BP-12],BX ; if (ccount < 0) goto reject; ; BX _ _ccount MOV BX,[BP-12] CMP BX,0 JGE X8 JMP _reject X8: ; maxLength = ((128 - pupOvWords) - 3) << 1; MOV WORD PTR [BP-16],0E4X ; if (ccount > maxLength) { ; BX _ _maxLength MOV BX,[BP-16] ; CX _ _ccount MOV CX,[BP-12] CMP CX,BX JLE X9 ; ccount = maxLength; ; BX _ _maxLength MOV BX,[BP-16] ; _ccount _ BX MOV [BP-12],BX ; core->count = Swab(maxLength); ; BX _ _core POP BX PUSH BX PUSH BX ; BX _ _maxLength MOV BX,[BP-16] CALL _Swab MOV CX,BX POP BX MOV [BX+6],CX ; }; X9: ; caddr = Swab(core->addrlo); ; BX _ _core POP BX PUSH BX MOV CX,[BX+2] MOV BX,CX CALL _Swab ; _caddr _ BX MOV [BP-6],BX ; cdata = &core->data[0]; ; BX _ _core POP BX PUSH BX ADD BX,8 ; _cdata _ BX MOV [BP-8],BX ; cAdvice = Swab(core->advice); ; DI _ _core POP DI PUSH DI MOV BX,[DI] CALL _Swab ; _cAdvice _ BX MOV [BP-10],BX ; if (dHost == 0) cAdvice &= 0x3fff; ; BX _ _dHost MOV BX,[BP-18] OR BX,BX JNZ X10 AND WORD PTR [BP-10],03FFFX X10: ; core->advice = Swab(advice); MOV BX,_advice CALL _Swab MOV CX,BX ; BX _ _core POP BX PUSH BX MOV [BX],CX ; pupType = pup->type; ; BX _ _pup MOV BX,[BP-4] MOV AL,[BX+3] XOR AH,AH ; _pupType _ AX MOV [BP-14],AX ; switch (pupType) { ; BX _ _pupType MOV BX,[BP-14] JR X11 ; case ELStateWrite: X13: ; case ELSingleStep: X14: ; case ELGoFromBreak: X15: ; if (dHost == 0) goto reject; ; BX _ _dHost MOV BX,[BP-18] OR BX,BX JNZ X16 JMP _reject X16: ; if (((int) caddr != 1) || (ccount != 28)) goto reject; ; BX _ _caddr MOV BX,[BP-6] CMP BX,1 JNZ X19 ; BX _ _ccount MOV BX,[BP-12] CMP BX,01CX X19: X18: JZ X17 JMP _reject X17: ; ByteBlt(mState, cdata, ccount); LEA BX,_mState PUSH BX ; BX _ _ccount MOV BX,[BP-12] ; CX _ _cdata MOV CX,[BP-8] CALL _ByteBlt POP DX ; case ELStateRead: X20: ; if ((int) caddr != 1) goto reject; ; BX _ _caddr MOV BX,[BP-6] CMP BX,1 JZ X21 JMP _reject X21: ; ByteBlt(cdata, mState, ccount); ; BX _ _cdata MOV BX,[BP-8] PUSH BX ; BX _ _ccount MOV BX,[BP-12] LEA CX,_mState CALL _ByteBlt POP DX ; pup->length = Swab((31 + ccount) & 0xfffe); ; BX _ _ccount MOV BX,[BP-12] ADD BX,01FX AND BX,0FFFEX CALL _Swab MOV CX,BX ; BX _ _pup MOV BX,[BP-4] MOV [BX],CX ; pup->type = pup->type + 1; ; BX _ _pup MOV BX,[BP-4] ; CX _ _pup MOV CX,[BP-4] MOV DI,CX MOV AL,[DI+3] INC AL MOV [BX+3],AL ; ReplyTo(cAdvice, pbi); ; BX _ _pbi MOV BX,[BP-2] ; CX _ _cAdvice MOV CX,[BP-10] CALL _ReplyTo ; if (pupType == ELStateWrite) GoNormal(); ; BX _ _pupType MOV BX,[BP-14] JR $+5 X11: JMP X23 CMP BX,0C4X JNZ X22 CALL _GoNormal X22: ; if (pupType == ELGoFromBreak) GoFromBreak(); ; BX _ _pupType MOV BX,[BP-14] CMP BX,0CCX JNZ X24 CALL _GoFromBreak X24: ; if (pupType == ELSingleStep) SingleStep(); ; BX _ _pupType MOV BX,[BP-14] CMP BX,0CAX JNZ X25 CALL _SingleStep X25: ; goto ok; JMP _ok ; case ELWrite: X26: ; if (dHost == 0) goto reject; ; BX _ _dHost MOV BX,[BP-18] OR BX,BX JNZ X27 JMP _reject X27: ; ByteBlt(caddr, cdata, ccount); ; BX _ _caddr MOV BX,[BP-6] PUSH BX ; BX _ _ccount MOV BX,[BP-12] ; CX _ _cdata MOV CX,[BP-8] CALL _ByteBlt POP DX ; case ELRead: X28: ; if (Ugt(caddr, 0xffcf)) goto reject; MOV BX,0FFCFX ; CX _ _caddr MOV CX,[BP-6] CALL _Ugt OR BX,BX JZ X29 JMP _reject X29: ; if (Ugt(ccount, 0xffd0 - ((int) caddr))) goto reject; ; BX _ _caddr MOV BX,[BP-6] MOV CX,0FFD0X SUB CX,BX MOV BX,CX ; CX _ _ccount MOV CX,[BP-12] CALL _Ugt OR BX,BX JZ X30 JMP _reject X30: ; ByteBlt(cdata, caddr, ccount); ; BX _ _cdata MOV BX,[BP-8] PUSH BX ; BX _ _ccount MOV BX,[BP-12] ; CX _ _caddr MOV CX,[BP-6] CALL _ByteBlt POP DX ; pup->length = Swab((31 + ccount) & 0xfffe); ; BX _ _ccount MOV BX,[BP-12] ADD BX,01FX AND BX,0FFFEX CALL _Swab MOV CX,BX ; BX _ _pup MOV BX,[BP-4] MOV [BX],CX ; pup->type = pup->type + 1; ; BX _ _pup MOV BX,[BP-4] ; CX _ _pup MOV CX,[BP-4] MOV DI,CX MOV AL,[DI+3] INC AL MOV [BX+3],AL ; ReplyTo(cAdvice, pbi); ; BX _ _pbi MOV BX,[BP-2] ; CX _ _cAdvice MOV CX,[BP-10] CALL _ReplyTo ; goto ok; JMP _ok ; case ELDebug: { X31: ; if (dHost != 0) CallDebugger(0xfffa); ; BX _ _dHost MOV BX,[BP-18] OR BX,BX JZ X32 MOV BX,0FFFAX CALL _CallDebugger X32: ; goto reject; JMP _reject ; }; ; case ELSWrite: X33: ; if (dHost == 0) goto reject; ; BX _ _dHost MOV BX,[BP-18] OR BX,BX JNZ X34 JMP _reject X34: ; SlaveBLT(caddr, cdata, ccount); /* how tell when it is done ? */ ; BX _ _caddr MOV BX,[BP-6] PUSH BX ; BX _ _ccount MOV BX,[BP-12] ; CX _ _cdata MOV CX,[BP-8] CALL _SlaveBLT POP DX ; case ELSRead: X35: ; SlaveBLT(cdata, caddr, ccount); ; BX _ _cdata MOV BX,[BP-8] PUSH BX ; BX _ _ccount MOV BX,[BP-12] ; CX _ _caddr MOV CX,[BP-6] CALL _SlaveBLT POP DX ; pup->length = Swab((31 + ccount) & 0xfffe); ; BX _ _ccount MOV BX,[BP-12] ADD BX,01FX AND BX,0FFFEX CALL _Swab MOV CX,BX ; BX _ _pup MOV BX,[BP-4] MOV [BX],CX ; pup->type = pup->type + 1; ; BX _ _pup MOV BX,[BP-4] ; CX _ _pup MOV CX,[BP-4] MOV DI,CX MOV AL,[DI+3] INC AL MOV [BX+3],AL ; ReplyTo(cAdvice, pbi); ; BX _ _pbi MOV BX,[BP-2] ; CX _ _cAdvice MOV CX,[BP-10] CALL _ReplyTo ; goto ok; JMP _ok ; case ELCall: X36: ; CallPkt(cdata); ; BX _ _cdata MOV BX,[BP-8] CALL _CallPkt ; pup->type = pup->type + 1; ; BX _ _pup MOV BX,[BP-4] ; CX _ _pup MOV CX,[BP-4] MOV DI,CX MOV AL,[DI+3] INC AL MOV [BX+3],AL ; ReplyTo(cAdvice, pbi); ; BX _ _pbi MOV BX,[BP-2] ; CX _ _cAdvice MOV CX,[BP-10] CALL _ReplyTo ; goto ok; JMP _ok ; default: goto reject; X37: JMP _reject ; }; JR X12 X23: MOV AL,BH OR AL,AL JNZ X37 MOV AL,BL CMP AL,0C4X JMPZ X13 CMP AL,0CAX JMPZ X14 CMP AL,0CCX JMPZ X15 CMP AL,0C6X JMPZ X20 CMP AL,0C0X JMPZ X26 CMP AL,0C2X JMPZ X28 CMP AL,0C8X JMPZ X31 CMP AL,0CEX JMPZ X33 CMP AL,0D0X JMPZ X35 CMP AL,0D2X JZ X36 JR X37 X12: _ok: ; ok: ; gotReply = true; MOV _gotReply,0FFFFX _reject: ; reject: ; }; MOV SP,BP POP BP RET; ; static ReplyTo(cAdvice, pbi) _ReplyTo: ; int cAdvice; ; struct PBI *pbi; PUSH BP MOV BP,SP PUSH CX PUSH BX ; { ; struct Pup *pup; ; struct EtherEncapsulation *ee; ; int temp; ; if (cAdvice & 0x4000) advice = cAdvice & 0x3fff; ADD SP,0FFFAX ; BX _ _cAdvice MOV BX,[BP-2] AND BX,04000X OR BX,BX JZ X38 ; BX _ _cAdvice MOV BX,[BP-2] AND BX,03FFFX MOV _advice,BX X38: ; pup = pbi->pup; ; BX _ _pbi MOV BX,[BP-4] MOV CX,[BX+6] ; _pup _ CX MOV [BP-6],CX ; temp = (int) pup; ; BX _ _pup MOV BX,[BP-6] ; _temp _ BX POP DX PUSH BX ; temp -= 4; SUB WORD PTR [BP-10],4 ; ee = (struct EtherEncapsulation *) temp; ; BX _ _temp POP BX PUSH BX ; _ee _ BX MOV [BP-8],BX ; MoveBlock(tlID, &pup->id[0], 2); LEA BX,_tlID PUSH BX ; BX _ _pup MOV BX,[BP-6] ADD BX,4 PUSH BX MOV BX,2 POP CX CALL _MoveBlock POP DX ; if (cAdvice & 0x8000) { ; BX _ _cAdvice MOV BX,[BP-2] AND BX,08000X OR BX,BX JZ X39 ; tlNet = pup->sPort.net; ; BX _ _pup MOV BX,[BP-6] MOV AL,[BX+14] XOR AH,AH MOV _tlNet,AX ; tlHost = pup->sPort.host; ; BX _ _pup MOV BX,[BP-6] MOV AL,[BX+15] XOR AH,AH MOV _tlHost,AX ; tlImHost = ee->src; ; BX _ _ee MOV BX,[BP-8] MOV AL,[BX+1] XOR AH,AH MOV _tlImHost,AX ; }; X39: ; if (pup->dPort.net != 0) localNet = pup->dPort.net; ; BX _ _pup MOV BX,[BP-6] MOV AL,[BX+8] OR AL,AL JZ X40 ; BX _ _pup MOV BX,[BP-6] MOV AL,[BX+8] XOR AH,AH MOV _localNet,AX X40: ; ee->dst = ee->src; ; BX _ _ee MOV BX,[BP-8] MOV AL,[BX+1] ; BX _ _ee MOV BX,[BP-8] MOV [BX],AL ; ee->src = EtherHost(); ; BX _ _ee MOV BX,[BP-8] PUSH BX CALL _EtherHost MOV AL,BL POP BX MOV [BX+1],AL ; ee->type = 2; ; BX _ _ee MOV BX,[BP-8] MOV WORD PTR [BX+2],2 ; SwapSourceAndDest(pup); ; BX _ _pup MOV BX,[BP-6] CALL _SwapSourceAndDest ; pup->transport = 0; ; BX _ _pup MOV BX,[BP-6] MOV BYTE PTR [BX+2],0 ; ReallySetCheckSum(pup); ; BX _ _pup MOV BX,[BP-6] CALL _ReallySetCheckSum ; SStartTx(pbi); ; BX _ _pbi MOV BX,[BP-4] CALL _SStartTx ; while (!SCheckTx(pbi)) CheckWDT(); X41: ; BX _ _pbi MOV BX,[BP-4] CALL _SCheckTx OR BX,BX JNZ X42 CALL _CheckWDT JR X41 X42: ; }; MOV SP,BP POP BP RET; ; SetCheckSum(pup) _SetCheckSum: ; int *pup; PUSH BP MOV BP,SP PUSH BX ; { ; pup[((Swab(*pup) +1) >> 1) - 1] = -1; ; DI _ _pup POP DI PUSH DI MOV BX,[DI] CALL _Swab INC BX SHR BX DEC BX ; CX _ _pup POP CX PUSH CX SAL BX ADD BX,CX MOV WORD PTR [BX],0FFFFX ; }; MOV SP,BP POP BP RET; ; CheckCheckSum(pup) _CheckCheckSum: ; int *pup; PUSH BP MOV BP,SP PUSH BX ; { ; int ck; PUSH DX ; ck = pup[((Swab(*pup) +1) >> 1) - 1]; ; DI _ _pup MOV DI,[BP-2] MOV BX,[DI] CALL _Swab INC BX SHR BX DEC BX ; CX _ _pup MOV CX,[BP-2] SAL BX ADD BX,CX MOV CX,[BX] ; _ck _ CX POP DX PUSH CX ; if ((ck == -1) || (ck == CheckSum(pup))) return(true); ; BX _ _ck POP BX PUSH BX CMP BX,0FFFFX JZ X45 ; BX _ _pup MOV BX,[BP-2] CALL _CheckSum ; CX _ _ck POP CX PUSH CX CMP CX,BX X45: X44: JNZ X43 MOV BX,0FFFFX MOV SP,BP POP BP RET; X43: ; return(false); XOR BX,BX MOV SP,BP POP BP RET; ; }; ; ReallySetCheckSum(pup) _ReallySetCheckSum: ; int *pup; PUSH BP MOV BP,SP PUSH BX ; { ; pup[((Swab(*pup) +1) >> 1) - 1] = CheckSum(pup); ; DI _ _pup POP DI PUSH DI MOV BX,[DI] CALL _Swab INC BX SHR BX DEC BX ; CX _ _pup POP CX PUSH CX SAL BX ADD BX,CX PUSH BX ; BX _ _pup MOV BX,[BP-2] CALL _CheckSum MOV CX,BX POP BX MOV [BX],CX ; }; MOV SP,BP POP BP RET; ; SwapSourceAndDest(pup) _SwapSourceAndDest: ; struct Pup *pup; PUSH BP MOV BP,SP PUSH BX ; { ; int temp[3]; ADD SP,0FFFAX ; MoveBlock(temp, &pup->dPort, 3); ;&_temp LEA BX,[BP-8] PUSH BX ; BX _ _pup MOV BX,[BP-2] ADD BX,8 PUSH BX MOV BX,3 POP CX CALL _MoveBlock POP DX ; MoveBlock(&pup->dPort, &pup->sPort, 3); ; BX _ _pup MOV BX,[BP-2] ADD BX,8 PUSH BX ; BX _ _pup MOV BX,[BP-2] ADD BX,0EX PUSH BX MOV BX,3 POP CX CALL _MoveBlock POP DX ; MoveBlock(&pup->sPort, temp, 3); ; BX _ _pup MOV BX,[BP-2] ADD BX,0EX PUSH BX MOV BX,3 ;&_temp LEA CX,[BP-8] CALL _MoveBlock POP DX ; }; MOV SP,BP POP BP RET; ; FirstSendState() _FirstSendState: PUSH BP MOV BP,SP ; { ; gotReply = false; MOV _gotReply,0 ; stateInterval = 1000; MOV _stateInterval,03E8X ; SendState(); CALL _SendState ; }; MOV SP,BP POP BP RET; ; CheckState() _CheckState: PUSH BP MOV BP,SP ; { ; if (gotReply) return; MOV BX,_gotReply OR BX,BX JZ X46 MOV SP,BP POP BP RET; X46: ; if (TmrExp(&stateTimer)) { LEA BX,_stateTimer CALL _TmrExp OR BX,BX JZ X47 ; if (stateInterval < 0) stateInterval = 1000; MOV BX,_stateInterval CMP BX,0 JGE X48 MOV _stateInterval,03E8X X48: ; if (stateInterval >= 5000) { MOV BX,_stateInterval CMP BX,01388X JL X49 ; tlNet = 0; MOV _tlNet,0 ; tlHost = 0; MOV _tlHost,0 ; localNet = 0; MOV _localNet,0 ; tlImHost = 0; MOV _tlImHost,0 ; }; X49: ; if (stateInterval < 30000) stateInterval += 1000; MOV BX,_stateInterval CMP BX,07530X JGE X50 ADD _stateInterval,03E8X X50: ; SendState(); CALL _SendState ; StartEL(); CALL _StartEL ; }; X47: ; }; MOV SP,BP POP BP RET; ; static SendState() _SendState: PUSH BP MOV BP,SP ; { ; struct Pup *pup; ; struct EtherEncapsulation *ee; ; int temp; ; struct Core *core; ADD SP,0FFF8X ; SLCReset(); CALL _SLCReset ; elPBI.pup = (struct Pup *) &elBuf[2]; LEA BX,_elBuf+4 MOV WORD PTR _elPBI+6,BX ; pup = elPBI.pup; MOV BX,WORD PTR _elPBI+6 ; _pup _ BX MOV [BP-2],BX ; temp = (int) pup; ; BX _ _pup MOV BX,[BP-2] ; _temp _ BX MOV [BP-6],BX ; temp -= 4; SUB WORD PTR [BP-6],4 ; ee = (struct EtherEncapsulation *) temp; ; BX _ _temp MOV BX,[BP-6] ; _ee _ BX MOV [BP-4],BX ; ee->src = tlImHost; ; BX _ _ee MOV BX,[BP-4] MOV AX,_tlImHost MOV [BX+1],AL ; pup->sPort.net = tlNet; ; BX _ _pup MOV BX,[BP-2] MOV AX,_tlNet MOV [BX+14],AL ; pup->sPort.host = tlHost; ; BX _ _pup MOV BX,[BP-2] MOV AX,_tlHost MOV [BX+15],AL ; pup->dPort.net = localNet; ; BX _ _pup MOV BX,[BP-2] MOV AX,_localNet MOV [BX+8],AL ; pup->dPort.host = EtherHost(); ; BX _ _pup MOV BX,[BP-2] PUSH BX CALL _EtherHost MOV AL,BL POP BX MOV [BX+9],AL ; pup->sPort.socket.LS = pup->dPort.socket.LS = 0; ; BX _ _pup MOV BX,[BP-2] ; CX _ _pup MOV CX,[BP-2] XCHG BX,CX MOV WORD PTR [BX+10],0 MOV BX,CX MOV WORD PTR [BX+16],0 ; pup->sPort.socket.ms = pup->dPort.socket.ms = 0x3000; ; BX _ _pup MOV BX,[BP-2] ; CX _ _pup MOV CX,[BP-2] XCHG BX,CX MOV WORD PTR [BX+12],03000X MOV BX,CX MOV WORD PTR [BX+18],03000X ; pup->type = ELBooted; ; BX _ _pup MOV BX,[BP-2] MOV BYTE PTR [BX+3],0C9X ; DoubleIncrement(tlID, 1); MOV BX,1 LEA CX,_tlID CALL _DoubleIncrement ; MoveBlock(&pup->id[0], tlID, 2); ; BX _ _pup MOV BX,[BP-2] ADD BX,4 PUSH BX MOV BX,2 LEA CX,_tlID CALL _MoveBlock POP DX ; core = (struct Core *) &pup->data; ; BX _ _pup MOV BX,[BP-2] ADD BX,014X ; _core _ BX POP DX PUSH BX ; core->count = Swab(38); ; BX _ _core POP BX PUSH BX PUSH BX MOV BX,026X CALL _Swab MOV CX,BX POP BX MOV [BX+6],CX ; core->addrhi = 0; ; BX _ _core POP BX PUSH BX MOV WORD PTR [BX+4],0 ; core->addrlo = Swab(1); ; BX _ _core POP BX PUSH BX PUSH BX MOV BX,1 CALL _Swab MOV CX,BX POP BX MOV [BX+2],CX ; ByteBlt(&core->data[0], mState, 48); ; BX _ _core POP BX PUSH BX ADD BX,8 PUSH BX MOV BX,030X LEA CX,_mState CALL _ByteBlt POP DX ; pup->length = Swab((31 + 48) & 0xfffe); MOV BX,04EX CALL _Swab MOV CX,BX ; BX _ _pup MOV BX,[BP-2] MOV [BX],CX ; ReplyTo(false, &elPBI); LEA BX,_elPBI XOR CX,CX CALL _ReplyTo ; SetTmr(stateInterval, &stateTimer); LEA BX,_stateTimer MOV CX,_stateInterval CALL _SetTmr ; }; MOV SP,BP POP BP RET; ; int *GetELBuf() _GetELBuf: PUSH BP MOV BP,SP ; { ; return(elBuf); LEA BX,_elBuf MOV SP,BP POP BP RET; ; }; ; int *GetDebugPtrs() _GetDebugPtrs: PUSH BP MOV BP,SP ; { ; return(&tlNet); LEA BX,_tlNet MOV SP,BP POP BP RET; ; }; ; SlaveBLT(dest, src, count) _SlaveBLT: ; int dest, src, count; PUSH BP MOV BP,SP PUSH CX PUSH BX ; { ; StoreW(src, BltFrom); MOV BX,0D9EAX ; CX _ _src MOV CX,[BP-2] CALL _StoreW ; StoreW(dest, BltTo); MOV BX,0D9ECX ; CX _ _dest MOV CX,[BP+4] CALL _StoreW ; StoreW(count >> 1, BltCount); ; BX _ _count POP BX PUSH BX SHR BX PUSH BX MOV BX,0D9E8X POP CX CALL _StoreW ; StartSlave(4, 0); XOR BX,BX MOV CX,4 CALL _StartSlave ; SetTmr(count, &dest); ;&_dest LEA BX,[BP+4] ; CX _ _count POP CX PUSH CX CALL _SetTmr ; while (!TmrExp(&dest)) CheckWDT(); X51: ;&_dest LEA BX,[BP+4] CALL _TmrExp OR BX,BX JNZ X52 CALL _CheckWDT JR X51 X52: ; }; MOV SP,BP POP BP RET; ; struct CPArgs { ; int proc; ; int nargs; ; int returnSlot; ; int args[5]; ; }; ; extern int stackLimit; ; extern int monEnd; ; CallPkt(cp) _CallPkt: ; struct CPArgs *cp; PUSH BP MOV BP,SP PUSH BX ; { ; int stklimit; PUSH DX ; BlockSwab(cp, 8); MOV BX,8 ; CX _ _cp MOV CX,[BP-2] CALL _BlockSwab ; if (cp->nargs > 5) return; ; BX _ _cp MOV BX,[BP-2] MOV CX,[BX+2] MOV BX,CX CMP BX,5 JLE X53 MOV SP,BP POP BP RET; X53: ; stklimit = stackLimit; MOV BX,_stackLimit ; _stklimit _ BX POP DX PUSH BX ; stackLimit = (int) &monEnd; LEA BX,_monEnd MOV _stackLimit,BX ; stackLimit += 20; ADD _stackLimit,014X ; cp->returnSlot = Apply(&cp->args[0], cp->proc, cp->nargs); ; BX _ _cp MOV BX,[BP-2] PUSH BX ; BX _ _cp MOV BX,[BP-2] ADD BX,6 PUSH BX ; DI _ _cp MOV DI,[BP-2] MOV BX,[DI] ; CX _ _cp MOV CX,[BP-2] MOV DI,CX MOV CX,[DI+2] XCHG BX,CX CALL _Apply POP DX MOV CX,BX POP BX MOV [BX+4],CX ; BlockSwab(cp, 8); MOV BX,8 ; CX _ _cp MOV CX,[BP-2] CALL _BlockSwab ; stackLimit = stklimit; ; BX _ _stklimit POP BX PUSH BX MOV _stackLimit,BX ; }; MOV SP,BP POP BP RET; ; BlockSwab(ptr, count) _BlockSwab: ; int *ptr, count; PUSH BP MOV BP,SP PUSH CX PUSH BX ; { ; int i; ; for (i = 0; i < count; i += 1) ptr[i] = Swab(ptr[i]); PUSH DX MOV WORD PTR [BP-6],0 X56: ; BX _ _count MOV BX,[BP-4] ; CX _ _i POP CX PUSH CX CMP CX,BX JGE X55 JR X54 X57: INC WORD PTR [BP-6] JR X56 X54: ; BX _ _i POP BX PUSH BX ; CX _ _ptr MOV CX,[BP-2] SAL BX ADD BX,CX PUSH BX ; BX _ _i MOV BX,[BP-6] ; CX _ _ptr MOV CX,[BP-2] SAL BX ADD BX,CX MOV CX,[BX] MOV BX,CX CALL _Swab MOV CX,BX POP BX MOV [BX],CX JR X57 X55: ; }; MOV SP,BP POP BP RET; ; Externals Declared Here PUBLIC _StartEL PUBLIC _CheckEL PUBLIC _CheckCheckSum PUBLIC _SlaveBLT PUBLIC _CallPkt PUBLIC _SwapSourceAndDest PUBLIC _ReallySetCheckSum PUBLIC _SetCheckSum PUBLIC _FirstSendState PUBLIC _CheckState PUBLIC _GetELBuf PUBLIC _GetDebugPtrs PUBLIC _BlockSwab C_CODE ENDS ; Number of Bytes of Code = 074CX, (1868)