|
发表于 2025-3-21 15:05:15
|
显示全部楼层
It looks like you're implementing a custom interrupt handler at `int 7Ch`, but you're encountering issues where the interrupt only executes once, the screen freezes, and subsequent executions do not work. Let's analyze the potential causes and solutions.
---
### **Potential Issues**
1. **Interrupt Handler Not Properly Installed**
- Your installation code copies the interrupt handler to `0:200h`, but it does not properly set the interrupt vector for `int 7Ch`. Instead, it modifies `es:[0]` and `es:[2]`, which are likely affecting `int 00h` (Divide by Zero Exception) instead of `int 7Ch`.
2. **Interrupt Handler Not Returning Properly**
- The handler should end with `iret`, which it does in `iret` at `iret: pop bx iret`. However, if the interrupt is not properly installed, it may not be executing at all.
3. **Interrupt Handler Overwriting Memory**
- The handler modifies video memory (`0xB8000`), but if `di` is not properly managed, it could be writing outside the intended range.
4. **Interrupt Vector Not Restored**
- If the program is forcefully closed, the interrupt vector remains pointing to an invalid memory location, causing subsequent executions to fail.
---
### **Suggested Fixes**
#### **1. Properly Set the Interrupt Vector**
Modify your installation code to correctly set `int 7Ch` in the interrupt vector table:
- mov ax, 0
- mov es, ax
- mov word ptr es:[7Ch * 4], 200h ; Offset of handler
- mov word ptr es:[7Ch * 4 + 2], 0 ; Segment of handler
复制代码
This ensures that `int 7Ch` correctly points to your handler.
#### **2. Ensure the Handler Returns Properly**
Your handler should always end with `iret` to return control to the calling program.
#### **3. Restore the Original Interrupt Vector on Exit**
Before exiting, restore the original interrupt vector to prevent issues in subsequent runs.
---
### **Next Steps**
- Try modifying your installation code to correctly set `int 7Ch`.
- If the issue persists, use a debugger (`debug.exe` or `TD`) to inspect the interrupt vector at `int 7Ch` (`d 0:7C*4`).
- If you still encounter issues, let me know what happens when you run `int 7Ch` manually in a debugger.
Would you like me to provide a corrected version of your installation code?
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。 |
|