; cmpioml.asm ; 8255 assistance ; L. Stewart, August 24, 1982 10:41 AM $INCLUDE(Lark.d) CCClock EQU 010H CCData EQU 020H CCCBar EQU 0EFH CCDBar EQU 0DFH SynTSN EQU 002H C_CODE SEGMENT C_DATA SEGMENT ; int vpio[6]; _vpio LABEL BYTE _vpioa DB 00H _vpiob DB 00H _vpioc DB 00H _vapioa DB 00H _vapiob DB 00H _vapioc DB 00H C_DATA ENDS ASSUME CS:C_CODE, DS:C_DATA pioports LABEL WORD DB pioa DB 0 DB piob DB 0 DB pioc DB 0 DB apioa DB 0 DB apiob DB 0 DB apioc DB 0 ; PIOOn(bits, port) _PIOOn LABEL NEAR MOV DI,OFFSET _vpio MOV AL,[DI][BX] OR AL,CL JMP piocom ; PIOOff(bits, port) _PIOOff LABEL NEAR MOV DI,OFFSET _vpio MOV AL,[DI][BX] XOR CL,0FFH AND AL,CL JMP piocom ; SetPIO(bits, port) _SetPIO LABEL NEAR MOV DI,OFFSET _vpio MOV AL,CL JMP piocom piocom: MOV [DI][BX],AL MOV SI,OFFSET pioports SAL BX,1 MOV DX,[SI][BX] OUT DX,AL RET ; int GetPIO(port) _GetPIO PROC MOV SI,OFFSET pioports SAL BX,1 MOV DX,[SI][BX] XOR AX,AX IN AL,DX MOV BX,AX RET _GetPIO ENDP ; Set up codec with time slot word passed in BX ; SetCodec(timeslot) _SetCodec PROC NEAR MOV AL,_vapioa AND AL,CCCBar ; clear clock AND AL,CCDBar ; clear data OUT apioa,AL MOV CX,8 OR AL,CCClock ; set clock MOV DL,AL tsnlow: ; wait for not TSN IN AL,pioc TEST AL,SynTSN JNZ tsnlow tsnhigh: ; wait for TSN IN AL,pioc TEST AL,SynTSN JZ tsnhigh tsloop: MOV AL,DL OR BL,BL JNS tsl0 OR AL,CCData ; possibly set data tsl0: OUT apioa,AL AND AL,CCCBar ; clear clock OUT apioa,AL SAL BX,1 LOOP tsloop AND AL,CCDBar ; clear data OUT apioa,AL MOV _vapioa,AL RET _SetCodec ENDP PUBLIC _vpio PUBLIC _vpioa PUBLIC _vpiob PUBLIC _vpioc PUBLIC _vapioa PUBLIC _vapiob PUBLIC _vapioc PUBLIC _PIOOn PUBLIC _PIOOff PUBLIC _SetPIO PUBLIC _GetPIO PUBLIC _SetCodec C_CODE ENDS END