944,066 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 4952
  • Assembly RSS
Jun 13th, 2006
0

hardware interrupt hangs

Expand Post »
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:

Assembly Syntax (Toggle Plain Text)
  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


Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
viermus is offline Offline
1 posts
since Jun 2006
Jun 13th, 2006
0

Re: hardware interrupt hangs

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.
Moderator
Reputation Points: 3281
Solved Threads: 894
Posting Sage
WaltP is offline Offline
7,747 posts
since May 2006
Jun 13th, 2006
0

Re: hardware interrupt hangs

Well go to www.google.com to check 4 what so ever u are looking 4
Reputation Points: 10
Solved Threads: 0
Newbie Poster
elektroniklotto is offline Offline
1 posts
since Jun 2006
Jun 13th, 2006
0

Re: hardware interrupt hangs

Quote 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:
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Jul 11th, 2006
0

Re: hardware interrupt hangs

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
thandermax is offline Offline
14 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: beginner compile problem
Next Thread in Assembly Forum Timeline: Displaying numeric data





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC