Hey, here is my working code for making "beep" sound for ~2-3 seconds.


in al,61h
or al,3
out 61h,al
;-------------
mov bx,440h
mov dx,12h
mov ax,34ddh
div bx

pushf
push ax
cli
mov al,0b6h
out 43h,al

pop ax
out 42h,al
mov al,ah
out 42h,al
popf


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

mov cx,0fh
mov dx,4240h
mov ah,86h
int 15h ; pauza o d?ugo?ci CX:DX mikrosekund

;-------------
in al,61h
and al,~3 ; zerujemy bity 0 i 1
out 61h,al


It's working correctly when it's working in standalone .com application, but when i use it in my INTERRUPT TAKEN CODE BLOCK then it gets crahed in line where "int 15h" is. I tryed to figure it out using/remove cli and sti, but it didn't help, what is wrong with this code ? Why I can't make int 15h inside interrupt taken, other things are working properly.


Thanks for help!
Posted on 2012-06-04 12:40:38 by hElllk
Well, a theory that I have is that the interrupt handler just takes too long, so there is a watchdog that complains. You can't just hog the system for 2-3 seconds in an int handler.
Posted on 2012-06-05 06:36:42 by Scali

Well, a theory that I have is that the interrupt handler just takes too long, so there is a watchdog that complains. You can't just hog the system for 2-3 seconds in an int handler.



Well, do you mean i should make beep sound shorter (in time line) ?

Well, I tried it out and it didn't work. I've read right here http://webpages.charter.net/danrollins/techhelp/0221.HTM that changing CD:DX will make make my sound different in time line, but i still get crash. Should i put there some kind of constant (special) value from some range of values to make it wouldn't carsh no more while in interrupt ?

Thanks for replaying!
Posted on 2012-06-05 10:58:45 by hElllk
No, Scali is stating, rightfully, that you do not run with interrupts disabled for that long.
Thus, for example, logically do the following:
1. Clear interrupts, start your beeping, set interrupts.
2. Wait X number of seconds.
3. Clear interrupts, stop beeping, Set interrupts.
Posted on 2012-06-05 11:39:20 by p1ranha
Aside from that there is still the obvious problem: You are using a virtualized environment, which does not behave 100% the same as an actual PC running an actual copy of MS-DOS, with an actual BIOS implementation in ROM.
Both NTVDM and Dosbox are quite poor emulators as far as compatibility goes.
I have seen code that works while it shouldn't, and code that shouldn't work, while it did.
If I want to be 100% sure that my code works, I pull out the old 486 and test.
Posted on 2012-06-05 13:26:02 by Scali