Hi, everyone!

I am trying to program (in assembler) a hardware interrupt at vector
72h, to beep twice.


The program seems to be running, and it looks like it is returning control to DOS. I can run it as many times as I want, the only problem is when I try to run anything else. My computer seems to hang (for some commands, such as dir, it just waits a long time, then finally shows me the contents of the current directory, but then a message is output on the screen: Cannot read from drive C).

If anyone could help, would be really great!

Here's the code:

;*************************************************************
;ISRSETUP.ASM   -  A program setting up an interrupt servive routine 
;                  as a Teminate-and-Stay-Resident (TSR) Program, which 
;                  can be called using Interrupt Request 72h            
;*************************************************************

.MODEL small
.STACK 200h   

.DATA
MASTR0 equ 20h
MASTR1 equ 21h
SLAVE0 equ 0A0h
SLAVE1 equ 0A1h


.CODE

main: 
jmp start

ToBeExec Proc Far
Pushf
Push dx         ;places (pushes) content of register ax onto stack
push ax         ;places (pushes) content of register dx onto stack        
push bx
push cx

sti
    mov     cx,2000                 ;1st beep tone frequency
    ;call    beep                    ;go sound the beep
;beep:
    mov     al,10110110b                    ;load control word
    out     43h,al                          ;send it
    mov     ax,cx                           ;tone frequency into AX
    out     42h,al                          ;send LSB
    mov     al,ah                           ;move MSB to AL
    out     42h,al                          ;send it
    in      al,61h                          ;get port 61 state
    or      al,00000011b                    ;turn on speaker
    out     61h,al                          ;speaker on now
    mov     bx, 600
pause1:
    mov     cx, 65535
pause2: 
    dec     cx
    jne     pause2
    dec     bx
    jne     pause1
    in      al,61h
    and     al,11111100b
    out     61h,al
;end_beep:
    

    mov     cx,2500                 ;2nd beep tone frequencybeep1:
       ; call    beep                    ;go sound the beep
    
;beep:
    mov     al,10110110b                    ;load control word
    out     43h,al                          ;send it
    mov     ax,cx                           ;tone frequency into AX
    out     42h,al                          ;send LSB
    mov     al,ah                           ;move MSB to AL
    out     42h,al                          ;send it
    in      al,61h                          ;get port 61 state
    or      al,00000011b                    ;turn on speaker
    out     61h,al                          ;speaker on now
    mov     bx, 600
pause3:
    mov     cx, 65535
pause4: 
    dec     cx
    jne     pause4
    dec     bx
    jne     pause3
    in      al,61h
    and     al,11111100b
    out     61h,al
;end_beep:


    ;jmp     end_beep                ;we're done
pop cx
pop bx
pop ax          ;retrieves (pops) content of register ax from stack
pop dx          ;retrieves (pops) content of register dx from stack
popf

IRET

ToBeExec Endp


start:


init_intctrl:
    mov     al,11h
    out     MASTR0,al
    mov     al,8
    out     MASTR1,al
    mov     al,4   
    out     MASTR1,al
    mov     al,1
    out     MASTR1,al
    mov     al,11h
    out     SLAVE0,al
    mov     al,70h
    out     SLAVE1,al
    mov     al,2
    out     SLAVE1,al
    mov     al,1
    out     SLAVE1,al


;Install the new interrupt vector 72h
mov ax, cs              ; get the code segment
mov ds, ax
mov dx, offset ToBeExec
mov ah, 25h             ; sets the interrupt vector
            ; DS:DX holds the address of the new interrupt procedure
mov al, 72h             ; defines the interrupt
int 21h


mov dx,00a0h            ; this number indicates how many "paragraphs" 
            ; of 16 bytes each will be reserved in memory 
            ; for the TSR program
mov ax, 3100h           ; Program Terminates and Stays Resident in memory 
int 21h
     
mov     ax,4c00h
int     21h

END     main

Well, you have a hard uninteruptible loop of 39,321,600 iterations. How long is this going to run do you think? And once it starts, it's going to run until completion. Remember, you are in an interrupt. The way I remember it, an interupt will not let the normal programs run until it's finished.

Well go to www.google.com to check 4 what so ever u are looking 4

Wow, and just as I was beginning to hope that the real posting geniuses had left us...

Let's start with your silly use of 4 and u. Such abbreviations are neither smart nor appropriate for a technical forum that non-native English speakers frequent. It also suggests that you're an idiot who is either too lazy to compose an intelligent post, or incapable of doing so. The latter is suggested by your ridiculous suggestion that Google is always the answer, and, especially in this case, that Google is some kind of source code analyzer and debugger.

You're off to a good start, and you've only made one post. :rolleyes:

DOS uses a internal DTA buffer to do it's internal disk access job.
Also u shold not interrupt the DOS in the middle of some work.. As DOS in nonreentrant.

U shold check the status of DOS BUSY FLAG , if it is 0 then run ur code or sheddule the code for latter time by int 8h hook.

This article has been dead for over six months. Start a new discussion instead.