hardware interrupt hangs

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2006
Posts: 1
Reputation: viermus is an unknown quantity at this point 
Solved Threads: 0
viermus viermus is offline Offline
Newbie Poster

hardware interrupt hangs

 
0
  #1
Jun 13th, 2006
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:

  1. ;*************************************************************
  2. ;ISRSETUP.ASM - A program setting up an interrupt servive routine
  3. ; as a Teminate-and-Stay-Resident (TSR) Program, which
  4. ; can be called using Interrupt Request 72h
  5. ;*************************************************************
  6.  
  7. .MODEL small
  8. .STACK 200h
  9.  
  10. .DATA
  11. MASTR0 equ 20h
  12. MASTR1 equ 21h
  13. SLAVE0 equ 0A0h
  14. SLAVE1 equ 0A1h
  15.  
  16.  
  17. .CODE
  18.  
  19. main:
  20. jmp start
  21.  
  22. ToBeExec Proc Far
  23. Pushf
  24. Push dx ;places (pushes) content of register ax onto stack
  25. push ax ;places (pushes) content of register dx onto stack
  26. push bx
  27. push cx
  28.  
  29. sti
  30. mov cx,2000 ;1st beep tone frequency
  31. ;call beep ;go sound the beep
  32. ;beep:
  33. mov al,10110110b ;load control word
  34. out 43h,al ;send it
  35. mov ax,cx ;tone frequency into AX
  36. out 42h,al ;send LSB
  37. mov al,ah ;move MSB to AL
  38. out 42h,al ;send it
  39. in al,61h ;get port 61 state
  40. or al,00000011b ;turn on speaker
  41. out 61h,al ;speaker on now
  42. mov bx, 600
  43. pause1:
  44. mov cx, 65535
  45. pause2:
  46. dec cx
  47. jne pause2
  48. dec bx
  49. jne pause1
  50. in al,61h
  51. and al,11111100b
  52. out 61h,al
  53. ;end_beep:
  54.  
  55.  
  56. mov cx,2500 ;2nd beep tone frequencybeep1:
  57. ; call beep ;go sound the beep
  58.  
  59. ;beep:
  60. mov al,10110110b ;load control word
  61. out 43h,al ;send it
  62. mov ax,cx ;tone frequency into AX
  63. out 42h,al ;send LSB
  64. mov al,ah ;move MSB to AL
  65. out 42h,al ;send it
  66. in al,61h ;get port 61 state
  67. or al,00000011b ;turn on speaker
  68. out 61h,al ;speaker on now
  69. mov bx, 600
  70. pause3:
  71. mov cx, 65535
  72. pause4:
  73. dec cx
  74. jne pause4
  75. dec bx
  76. jne pause3
  77. in al,61h
  78. and al,11111100b
  79. out 61h,al
  80. ;end_beep:
  81.  
  82.  
  83. ;jmp end_beep ;we're done
  84. pop cx
  85. pop bx
  86. pop ax ;retrieves (pops) content of register ax from stack
  87. pop dx ;retrieves (pops) content of register dx from stack
  88. popf
  89.  
  90. IRET
  91.  
  92. ToBeExec Endp
  93.  
  94.  
  95. start:
  96.  
  97.  
  98. init_intctrl:
  99. mov al,11h
  100. out MASTR0,al
  101. mov al,8
  102. out MASTR1,al
  103. mov al,4
  104. out MASTR1,al
  105. mov al,1
  106. out MASTR1,al
  107. mov al,11h
  108. out SLAVE0,al
  109. mov al,70h
  110. out SLAVE1,al
  111. mov al,2
  112. out SLAVE1,al
  113. mov al,1
  114. out SLAVE1,al
  115.  
  116.  
  117. ;Install the new interrupt vector 72h
  118. mov ax, cs ; get the code segment
  119. mov ds, ax
  120. mov dx, offset ToBeExec
  121. mov ah, 25h ; sets the interrupt vector
  122. ; DS:DX holds the address of the new interrupt procedure
  123. mov al, 72h ; defines the interrupt
  124. int 21h
  125.  
  126.  
  127. mov dx,00a0h ; this number indicates how many "paragraphs"
  128. ; of 16 bytes each will be reserved in memory
  129. ; for the TSR program
  130. mov ax, 3100h ; Program Terminates and Stays Resident in memory
  131. int 21h
  132.  
  133. mov ax,4c00h
  134. int 21h
  135.  
  136. END main


Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: hardware interrupt hangs

 
0
  #2
Jun 13th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 1
Reputation: elektroniklotto is an unknown quantity at this point 
Solved Threads: 0
elektroniklotto elektroniklotto is offline Offline
Newbie Poster

Re: hardware interrupt hangs

 
0
  #3
Jun 13th, 2006
Well go to www.google.com to check 4 what so ever u are looking 4
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,698
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 728
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: hardware interrupt hangs

 
0
  #4
Jun 13th, 2006
Originally Posted by elektroniklotto
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:
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 14
Reputation: thandermax is an unknown quantity at this point 
Solved Threads: 0
thandermax thandermax is offline Offline
Newbie Poster

Re: hardware interrupt hangs

 
0
  #5
Jul 11th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC