;Alto->8086 small-c compiler rev 2.0 C←CODE SEGMENT $INCLUDE(8086LIB.D) $INCLUDE(DI2001.DEC) ASSUME CS:C←CODE, DS:C←DATA ; #include "Ec.h" ; extern EnableInt(); ; extern IWDC(); ; extern DWDC(); ; extern Enqueue(); ; extern Dequeue(); ; extern InitQueue(); ; extern Crypt(); ; extern EncEnd(); ; extern ResetEncInt(); ; extern Call1(); ; extern CallDebugger(); ; extern MoveBlock(); ; struct Queue enciq; ; struct ECB *ecbwork; ; Encrypt(p) ←Encrypt: ; struct ECB *p; PUSH BP MOV BP,SP PUSH BX ; { ; if (p->proc == 0) CallDebugger(0x8008); ; BX ← ←p POP BX PUSH BX MOV CX,[BX+14] OR CX,CX JNZ X1 MOV BX,08008X CALL ←CallDebugger X1: ; if (p->count == 0) { ; BX ← ←p POP BX PUSH BX MOV CX,[BX+8] OR CX,CX JNZ X2 ; Call1(p->proc, p->item); ; BX ← ←p POP BX PUSH BX MOV CX,[BX+14] ; BX ← ←p POP BX PUSH BX MOV AX,[BX+12] MOV BX,AX CALL ←Call1 ; return; MOV SP,BP POP BP RET; ; }; X2: ; if (p->kp == 0) { ; BX ← ←p POP BX PUSH BX MOV CX,[BX+2] OR CX,CX JNZ X3 ; MoveBlock(p->dstp, p->srcp, p->count >> 1); ; BX ← ←p POP BX PUSH BX MOV CX,[BX+6] PUSH CX ; BX ← ←p MOV BX,[BP-2] MOV CX,[BX+4] ; BX ← ←p MOV BX,[BP-2] MOV AX,[BX+8] SHR AX MOV BX,AX CALL ←MoveBlock POP DX ; Call1(p->proc, p->item); ; BX ← ←p POP BX PUSH BX MOV CX,[BX+14] ; BX ← ←p POP BX PUSH BX MOV AX,[BX+12] MOV BX,AX CALL ←Call1 ; }; ; else { JR X4 X3: ; Enqueue(&enciq, p); ; BX ← ←p POP BX PUSH BX LEA CX,←enciq CALL ←Enqueue ; IWDC(); /* don't think this is needed */ CALL ←IWDC ; if (ecbwork == 0) { MOV BX,←ecbwork OR BX,BX JNZ X5 ; ecbwork = Dequeue(&enciq); LEA BX,←enciq CALL ←Dequeue MOV ←ecbwork,BX ; if (ecbwork != 0) { MOV BX,←ecbwork OR BX,BX JZ X6 ; if (!Crypt(ecbwork)) CallDebugger(0x8001); MOV BX,←ecbwork CALL ←Crypt OR BX,BX JNZ X7 MOV BX,08001X CALL ←CallDebugger X7: ; }; X6: ; }; X5: ; DWDC(); /* don't think this is needed */ CALL ←DWDC ; }; X4: ; }; MOV SP,BP POP BP RET; ; static myEncInt() ←myEncInt: PUSH BP MOV BP,SP ; { ; struct ECB *p; ; if (!EncEnd()) CallDebugger(0x8007); /* shut down dma */ PUSH DX CALL ←EncEnd OR BX,BX JNZ X8 MOV BX,08007X CALL ←CallDebugger X8: ; if (ecbwork == 0) { MOV BX,←ecbwork OR BX,BX JNZ X9 ; DoEOI(); CALL ←DoEOI ; CallDebugger(0x8006); MOV BX,08006X CALL ←CallDebugger ; }; X9: ; p = ecbwork; MOV BX,←ecbwork ; ←p ← BX POP DX PUSH BX ; ResetEncInt(); CALL ←ResetEncInt ; ecbwork = Dequeue(&enciq); LEA BX,←enciq CALL ←Dequeue MOV ←ecbwork,BX ; if (ecbwork != 0) { MOV BX,←ecbwork OR BX,BX JZ X10 ; if (!Crypt(ecbwork)) { MOV BX,←ecbwork CALL ←Crypt OR BX,BX JNZ X11 ; DoEOI(); CALL ←DoEOI ; CallDebugger(0x8001); MOV BX,08001X CALL ←CallDebugger ; }; X11: ; }; X10: ; Call1(p->proc, p->item); /* called at interrupt level */ ; BX ← ←p POP BX PUSH BX MOV CX,[BX+14] ; BX ← ←p POP BX PUSH BX MOV AX,[BX+12] MOV BX,AX CALL ←Call1 ; return(true); MOV BX,0FFFFX MOV SP,BP POP BP RET; ; }; ; InitEncrypt() ←InitEncrypt: PUSH BP MOV BP,SP ; { ; ResetEncInt(); CALL ←ResetEncInt ; InitQueue(&enciq); LEA BX,←enciq CALL ←InitQueue ; ecbwork = 0; MOV WORD PTR ←ecbwork,0 ; EnableInt(&myEncInt, EncTyp); MOV BX,2 MOV CX,OFFSET ←myEncInt CALL ←EnableInt ; }; MOV SP,BP POP BP RET; ; Externals Declared Here PUBLIC ←enciq PUBLIC ←ecbwork PUBLIC ←Encrypt PUBLIC ←InitEncrypt C←CODE ENDS ; Number of Bytes of Code = 012AX, (298)