Re: Open the CD-ROM



almas wrote:
Hi Franck,
Hi every body.

Yes, i have a file, but i do not know who built it.
May be the author will not aggree i send it here.

Always more fun if you haven't got permission. :)

I try to compile the solution below,
With A86 ; i have error with BUFR and HDR
and with "add si, byte 5

Yeah, for A86 you'd need to add "offset" in a number of places. Just "add si, 5" would be fine for A86 (Nasm is rather brain-dead and stores the "5" as two bytes if we don't say "byte" - or use the "-O" switch.

So i try nasm, but it just make a file with 8 bytes

Odd. More than that in just the .data section! What were the 8 bytes? (not a rhetorical question - I really want to know what Nasm did here!)

I'll try to hint how you'd have to "translate" this back to A86... I imagine Donald Davis' original post was in Masm/Tasm syntax, which would probably assemble with A86, but I seem not to have saved the original... Can't find it, anyway...

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

IIRC, A86 does something weird with "section .data" (makes it disappear?) - you may want to call it something else.

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

hdr dup 26 (?)

bufr resb 130

etc.

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

offset

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.

offset

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.

lose the "byte"

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

Might need to lose "short", too.

; 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

offset

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

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

offset

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 ... Request header data below will be written in header data block as program ...
    (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)
  • Problem with concatenate avi files and play videos
    ... I use these following command to concatenate some small AVI files to ... a bigger AVI file. ... mov = addframe; ...
    (comp.soft-sys.matlab)