title MSDOS 2.00 Function Library for Lattice C include mc.ash .model small .code ;; ;;FUNCTION: Perform IO device control and ;; status functions. ;; ;;CALL: ;; val= _ioctl(func,handle,data,dummy) ;; val= _ioctl(func,handle,buff,count) ;; ;; int val; ret value or flag ;; int func,handle,dummy,count; ;; char *buff; ;; ;;RETURN: See below ;; VAL returns as -1 if any error. ;; ;;DESCRIPTION: ;; IOCTL get/set device information. The ;; args and return values depend on the ;; function: ;; ;;func == 0 get ;;func == 1 set ;; Get or set device info on (handle). ;; 0x80 Is a device (else file) ;; 0x01 Console input ;; 0x02 Console out ;; 0x04 Null device ;; 0x08 Clock device ;; 0x10 Special (fast) device ;; 0x20 Raw mode ;; 0x40 EOF on input ;; 0x4000 Accepts control strings ;; ;;func == 2 read ;;func == 3 write ;; Read or write (count) bytes from ;; the control channel. ;; ;;func == 4 read ;;func == 5 write ;; Same as 2,3, except (handle) is drive ;; number; 0 == default, 1 == A:, etc. ;; ;;func == 6 input status ;;func == 7 output status ;; if (handle) is a device, returns 0 if ;; not ready, else non-zero if device is ;; ready. For files, output always ready, ;; input always ready until EOF hit. ;; ;;CAUTIONS: ;;ASSUMPTIONS: ;; ;;LONG 32 bits (4 bytes) ;;INT 16 bits (2 bytes) ;;CHAR 8 bits (1 byte) page func __ioctl mov al,arg0 ;func mov bx,arg1 ;handle if long lds dx,dword ptr arg2 mov cx,arg4 else mov dx,arg2 ;data/buff mov cx,arg3 ;dummy/count endif mov ah,68 int 33 jnc _io1 ;if error, mov ax,-1 ;return -1 jmp short _ioz _io1: cmp word ptr arg0,2 ;functions 0,1 jae _io2 ;return from DX mov ax,dx jmp short _ioz _io2: cmp word ptr arg0,6 ;functions 2-5 jb _ioz ;return from AX mov ah,0 ;6,7 from AL _ioz: endf __ioctl end