Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Vista with 16-bits masm : unable to play tune smoothly

ciellecielle Posts: 11Member
[color=Purple]Hi all,

Hereby i would like to asking for consult regarding the problem that i encountered when attempt to output a music tune with masm16 bits programing..

below is my code
[/color][size=2][/size]

title music sound
;title sound-"pak belalang"- lagu P.Ramli
.model small


.code
.startup

mov al, 0b6h ;control byte: conter 2, lsb, msb, binary
out 43h, al ;send the control byte to ctrl reg.

;---------------------------------------------------------------

;load counter 2 value for 8C2
mov ax, 0239h ; for 8C2 note
out 42h, al ; lower byte
mov al, ah
out 42h, al ; higher byte
;turn the speaker on
call spk8

spk8 proc ;
;turn the speaker on
in al, 61h ; get the current setting of port b
mov ah, al
or al, 00000011b
out 61h, al ; turn the speaker on
call delay
call delay
call delay
call delay
call delay
;call delay
;call delay
;call delay
mov al, ah
out 61h, al ; turn off the speaker
call delay_off

ret
spk8 endp

delay proc near
mov cx, 19157 ;16578*15.08 microseconds = 250 ms
push ax

wait1:
in al,61h
and al, 10h
cmp al, ah
je wait1
mov ah, al
loop wait1

pop ax
ret
delay endp

delay_off proc near
mov cx, 15326 ; 1326*15.08 micro seconds = 20ms
push ax
tunggu: in al, 61h
and al,10h ; check pb4
cmp al,ah ;
mov ah,al ; save the new pb4 status
loop tunggu ; continue until cx becomes 0
pop ax
ret
delay_off endp



end



[color=Purple]At the end, i am able to assemble the code.. yet the sound is weird when run in Vista . 'Tok tok tok' sound is heard. But this code run smoothly with window XP.

Kindly advise pls where should i concern on my code in order to make it output the correct pitch.
[/color][size=2][/size]
Thanks & regards
Cielle


Comments

  • jeffleydajeffleyda Posts: 390Member
    I'm surprised it works under XP.
    Direct hardware access, like you're program is doing, is something that windows is trying to stop. Each time your program wants to talk to hardware, it has to "ask" the O/S if it's ok. If the O/S is doing something else, say, checking your hard drive for illegal software, or phoning home, or sending spam, it can delay your program from having access to the hardware.

    Vista is doing more background tasks than XP apparently.

    You could:
    a) turn off services that vista is running so that your program runs smoother.
    b) try calling the "delay" routine less often, or with a smaller delay
    c) change your delay routine to use a time based service instead of more direct hardware access.
    d) try your program inside DOSBox, which can help with older 16bit programs that do direct hardware accesses.


Sign In or Register to comment.