Re: Open the CD-ROM



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
;-----------------

.



Relevant Pages

  • Re: Open the CD-ROM
    ... mov cl, bl; get number of cd-rom drives ... 5; command to close tray ... the request header's subunit byte for calls to INT 2Fh, ...
    (alt.lang.asm)
  • Re: Open the CD-ROM
    ... i have error with BUFR and HDR ... mov cl, bl; get number of cd-rom drives ...
    (alt.lang.asm)
  • Re: Open the CD-ROM
    ... mov cl, bl; get number of cd-rom drives ... the request header's subunit byte for calls to INT 2Fh, ... Request header data below will be written in header data block as ...
    (alt.lang.asm)
  • Re: Saving MOV extension files on a CD
    ... I need to send a set of 20 to 25 MOV extension files (jazz drum ... these drives? ... Nero has clipped the first few frames in each MOV file - ...
    (rec.video.desktop)