/* This Code was written by Digital Solutions and is hereby placed in the Public Domain under GNU Public License, (Please see attached Copy) I, , have agreed to co-ordinate the changes made to mxsub and pass them back to Digital Solutions and others */ #define MAX_DRIVES 10 #define TRUE 1 #define FALSE 0 int show_regs(); static unsigned _rax, _rbx, _rcx, _rdx, _res; static unsigned char drive_nos[ MAX_DRIVES]; static char drives = 0; main( argc, argv) /* chain into specified vector & exit */ int argc; char *argv[]; { char *p, c, flag, x; /* Scan & parse drive list */ printf( "DIGITAL SOLUTIONS PTY. LTD. MSCDX emulater functions 0 and 0dHex\n"); if( argc < 2) { printf( "Usage - MXSUB drive_letter drive_letter ...\n"); exit(1); } if( argc > MAX_DRIVES+1) { printf( "Maximum of %d drives supported\n", MAX_DRIVES); exit(2); } --argc; for( drives = 0; drives < MAX_DRIVES && drives < argc; ++drives) { p = argv[ drives+1]; c = *p; if( !isalpha( c)) { printf( "Argument No. %d (%c) not a vaild drive\n", drives+1,c); exit(3); } drive_nos[ drives] = toupper( c) - 'A'; } /* Have all drives, now sort into ascending order - bsort */ do { flag = FALSE; for( x = 0; x < drives-1; ++x) { if( drive_nos[x] > drive_nos[x+1]) /* Need swap */ { c = drive_nos[x+1]; drive_nos[x+1] = drive_nos[x]; drive_nos[x] = c; flag = TRUE; } } } while( flag); printf( "Installed for drives"); for( x = 0; x < drives; ++x) { printf( " %c:", drive_nos[x] + 'A'); } printf( "\n"); #asm jmp arnd ;jump around vector save save_ds dw 0 chain_vec dw 0,0 arnd: mov word ptr cs:save_ds,ds ;save data segment for interrupt handlers mov word ptr cs:save_ds,ds ;save data segment for interrupt handlers mov bx,02fh*4 ;point to interrupt vector mov ax,0 mov es,ax ;vector ->chain_vec mov ax,es:[bx] mov word ptr cs:chain_vec,ax mov ax,es:2[bx] mov word ptr cs:chain_vec+2,ax #endasm ; install_vector(0x2f, show_regs); ; #asm mov ax,3100h ;exit but stay resident code mov dx,120h ;paragraphs to save including code int 21h ;ask dos to do it #endasm ; } show_regs() { char *p, x; #asm ; mov sp,bp ; pop bp ; jmp far ptr cs:[chain_vec] ;& continue to bios push ds push es push ax push bx push cx push dx mov ds,cs:save_ds ;establish envoirenment ; move register contents to where we can get them mov word ptr _rax_,ax mov word ptr _rbx_,bx mov word ptr _rcx_,cx mov word ptr _rdx_,dx mov word ptr _res_,es #endasm if( (_rax & 0xff00) == 0x1500) { ; #asm pop dx pop cx pop bx pop ax pop es #endasm ; switch( _rax & 0xff) { case 0: /* Func 0 */ _rbx = drives; /* # of drives */ _rcx = drive_nos[0]; /* First drive */ break; case 0x0d: /* func 13 */ p = (char *)((((long) _res) << 16) | _rbx); /* o/p buffer ptr */ for( x = 0; x < drives; ++x) { *p++ = drive_nos[x]; } break; default: ; #asm mov ax,3 ;set video mode 3 int 10h #endasm ; printf( "MXSUB error - unsupported function %02x (Hex)", _rax & 0xff); /* printf( "\nax:%04x bx:%04x cx:%04x dx:%04x es:%04x\n", _rax,_rbx,_rcx,_rdx,_res); */ ki(); break; } ; #asm mov ax,word ptr _rax_ mov bx,word ptr _rbx_ mov cx,word ptr _rcx_ mov dx,word ptr _rdx_ mov es,word ptr _res_ pop ds mov sp,bp pop bp iret #endasm ; } ; #asm pop dx pop cx pop bx pop ax pop es pop ds mov sp,bp pop bp jmp far ptr cs:[chain_vec] ;& continue to bios #endasm } putchar( c) char c; { if( c == '\n') putchar( '\r'); ; #asm mov ah,14 mov al,[6+bp] mov bx,7 mov cx,1 int 10h #endasm ; } ki() { #asm mov ah,0 ;get char from keyboard func int 16h ;call bios #endasm } install_vector( vector_no, new_vector) char vector_no; int (*new_vector)(); { int (**vptr)(); /* pointer to vector */ vptr = (long)vector_no << 2; ; #asm cli ;interrupts off #endasm *vptr = new_vector; /* install new vector */ ; #asm sti #endasm } isalpha( c) char c; { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } toupper( c) char c; { if( c >= 'a' && c <= 'z') return (c-'a') + 'A'; return c; }