Re: Open the CD-ROM
- From: Frank Kotler <fbkotler@xxxxxxxxxxx>
- Date: Sun, 28 Oct 2007 04:03:55 GMT
alex wrote:
yep
"Yep" what? You do have a file? We ain't gonna believe it until we see it!
I don't recall if this one actually worked for me or not...
Best,
Frank
; opens or closes CD-ROM tray
; written by Donald G. Davis - dgdavis<pigstail>nyx10.nyx.net
; translated to Nasm and "diddled" - fbkotler<pigstail>attbi.com
;
; nasm -f bin -o cdtray.com cdtray.asm
org 100h
section .data
msg DB 0Dh,0Ah,"Open/close CD-ROM drive tray. Usage:",0Dh,0Ah
DB "[PROGNAME] O [CD-ROM DRIVE LETTER] or "
DB "[PROGNAME] C [CD-ROM DRIVE LETTER].",0Dh,0Ah,"$"
section .bss
hdr resb 26
bufr resb 130
section .text
mov ax, 1500h
int 2Fh
mov cl, bl ; get number of cd-rom drives
mov al, [5Dh] ; let dos parse it - FCB's have
mov dl, [6Dh] ; our two parameters all uppercased
sub dl, 'A' ; convert drive letter to number
js usage
cmp al, 'O'
mov dh, 0 ; command to open tray
jz do_it
cmp al, 'C'
mov dh, 5 ; command to close tray
jnz usage
do_it:
; The following block sets in AH a subunit number corresponding to the order
; of the drive. This is redundant if running under MSCDEX, SHSUCDX or the
; Win9x CD-ROM driver, but is needed under NWCDEX, which doesn't initialize
; the request header's subunit byte for calls to INT 2Fh, function 1510h.
mov ax, 1501h ; "Get CD-ROM Drive Device List" function
mov bx, bufr ; Put device list incl. subunit nos. in buffer
int 2Fh ; to associate correct subunit no. with drive
mov si, bx ; Copy device list addr. to another pointer reg.
mov bx, hdr ; Set pointer register to list of drive nos.
mov ax, 150Dh ; Get CD-ROM drive letter(s) into buffer
int 2Fh
RPT: mov ah, [si] ; Get subunit no. into AH
cmp [bx], dl ; Drive on command line matches one in buffer?
je NXT ; If so, valid CD-ROM drive; make driver request
inc bx ; If not, prepare to check next drive no.
add si, byte 5 ; Prepare to store next subunit no.
loopne RPT ; If drive didn't match, loop until all checked
jmp short TRM1 ; If CX=0, no match to drive on command line; abort
; Request header data below will be written in header data block as program
; executes. The drive number list, which has served its purpose, will be
; overwritten.
NXT: mov cl, dl ; Get drive no. into proper register for call
mov bx, hdr ; Prepare to store parameters in request header
mov byte [bx], 0Dh ; Set header length byte of request header
mov byte [bx + 1], AH ; Set subunit number for specified drive
mov byte [bx + 2], 0Ch ; Set control code byte of request header
mov [bx + 10h], CS ; Set CD-ROM IOCTL output request header
; transfer address to this program's seg.
mov word [bx + 0Eh], hdr + 12h ; and proper offset
mov [bx + 12h], DH ; Set command code to open or close door
mov ax, 1510h ; Send CD-ROM device driver request
; to open or close door
int 2Fh ; On entry: BX = addr. of request header; CX = drive no.
mov AL, [bx + 3] ; Use low byte of status word as exit code
jmp short TRM0 ; (0: no error; other: driver error occurred)
usage:
TRM1: mov ah, 9 ; Terminate after message if command line wrong
mov dx, msg ; Display usage message
int 21h
mov al, 1 ; If here, error in parameters; set exit code=1
TRM0: mov ah, 4Ch ; Terminate
int 21h
;-----------------
.
- Follow-Ups:
- Re: Open the CD-ROM
- From: almas
- Re: Open the CD-ROM
- From: alex
- Re: Open the CD-ROM
- References:
- Open the CD-ROM
- From: almas
- Re: Open the CD-ROM
- From: alex
- Open the CD-ROM
- Prev by Date: Re: Open the CD-ROM
- Next by Date: Re: Open the CD-ROM
- Previous by thread: Re: Open the CD-ROM
- Next by thread: Re: Open the CD-ROM
- Index(es):
Relevant Pages
|