通用袖珍CD播放器
#2 源程序清单(编译环境:486 Intel DX2/66、DOS 6.22、MASM 5.0):
Code Segment
ORG 100h
Assume cs:code,ds:code,
es:code
Start:mov ax,cs
mov ds,ax
mov Word ptr Head[10h],ax
mov ax,1500h
int 2fh ;取得光驱驱动器号,在CX中返回
mov CDRom,cx
mov Buf[0],0ah
mov ax,cs
mov es,ax
mov bx,Offset Head
mov ax,1510h
int 2fh ;取得CD盘信息,在变量Buf中返回
mov al,Buf[5]
mov cl,60
mul cl
mov bx,0
mov bl,Buf[4]
add ax,bx
mov Word ptr Play[12h],ax
mov Buf[0],0bh
mov Buf[1],1
mov ax,cs
mov es,ax
mov bx,Offset Head
mov cx,CDRom
mov ax,1510h
int 2fh ;第一首歌信息,在变量Buf中返回
mov al,Buf[2]
mov Play[0Eh],al
mov al,Buf[4]
mov Play[10h],al
mov cl,60
mul cl
mov bx,0
mov bl,Buf[3]
mov Play[0Fh],bl
add bx,ax
mov ax,Word ptr Play[12h]
sub ax,bx
mov cx,75
mul cx
mov Play[14h],dl
mov Play[13h],ah
mov Play[12h],al
mov ax,cs
mov es,ax
mov bx,Offset Play
mov cx,CDRom
mov ax,1510h
int 2fh ;播放CD,控制信息在变量Play中
mov ax,4c00h
int 21h
Buf db 7 dup(0)
Head db 04h,00h,03h,11 dup(0)
dw Offset Buf
dw 00h
db 07h
db 7 dup(0)
Play db 16h,00h,84h,10 dup(0),01h,7 dup(0),00h
CDRom dw 0
Code Ends
End Start