ISR之后,程序将继续返回同一行.(程序集8086) [英] Program keeps returning to same line after ISR. (Assembly 8086)

查看:58
本文介绍了ISR之后,程序将继续返回同一行.(程序集8086)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理中断,并且在运行代码时遇到了这个问题:

I'm working with interrupts and I'm facing this problem while running my code:

DATA SEGMENT
    INPUTV DW 0035H, 0855H, 2011H, 1359H
    OUTPUTV DB 4 DUP(0)
    DIVIDER DB 09
    ERROR_FLAG DB 0
DATA ENDS

_STACK SEGMENT STACK
    DW 100 DUP(0)
    TOP_STACK LABEL WORD
_STACK ENDS

CODE SEGMENT
    ASSUME CS:CODE, DS:DATA, SS:_STACK
MAIN:
    MOV AX, _STACK
    MOV SS, AX
    MOV SP, OFFSET TOP_STACK
    MOV AX, DATA
    MOV DS, AX

    MOV AX, 0000H
    MOV ES, AX
    MOV WORD PTR ES:0002, SEG INT_PROC  ;PUSHING CS TO STACK
    MOV WORD PTR ES:0000, OFFSET INT_PROC   ;PUSHING IP TO STACK

    MOV SI, OFFSET INPUTV
    MOV BX, OFFSET OUTPUTV

    MOV CX, 4H
REPEAT:
    MOV AX, [SI]
    DIV DIVIDER
    CMP ERROR_FLAG, 1H
    JE ERROR_ENCOUNTER
    MOV [BX], AL
    JMP SKIP
ERROR_ENCOUNTER:
    MOV BYTE PTR [BX], 0H
    MOV ERROR_FLAG, 0H
SKIP:
    ADD SI,2
    INC BX
    LOOP REPEAT
    INT 3H
CODE ENDS

INT_SEG SEGMENT 
    ASSUME CS:INT_SEG
INT_PROC PROC
        MOV ERROR_FLAG, 1
        IRET
    INT_PROC ENDP
INT_SEG ENDS

END MAIN

程序从IRET指令从ISR(这里是INT_PROC)返回之后

After the program returns from the ISR (here INT_PROC) from IRET instruction

    INT_PROC PROC
            MOV ERROR_FLAG, 1
            IRET

它正在执行以下行:

    DIV DIVIDER

一次又一次地到达:

    CMP ERROR_FLAG, 1H

在此处调试图像

我在论坛上也发现了这一点:

I found this in the forum which also says the same:

返回中断后程序计数器的位置处理程序?

为什么会发生这种情况,我该如何解决?请帮忙.

why is that happening and how can i solve it? please help.

推荐答案

x86体系结构定义了三类软件生成的中断:

The x86 architecture defines three classes of software-generated interrupts:

  • 陷阱,显式和有意调用的中断.这些通常是 INT 指令的结果,本身并不表示问题.推送的IP是以下指令的IP,因此在返回处理程序之后,不会重试该指令.或者,如果无法解决故障,那么它可能只是扼杀了该过程.
  • 故障,例如页面错误和被零除.这些指示不完整的指令.推送的IP是产生故障的指令的IP;中断处理程序有机会尝试清除问题(最常见的情况是,通过在导致页面错误的内存页面中进行分页),然后重试该指令.
  • 中止,这是一种异常类型的故障,基本上无法恢复(通过终止过程除外).中断处理程序不应返回.
  • Traps, explicitly and intentionally invoked interrupts. These are usually the result of the INT instruction, and don't indicate a problem per se. The pushed IP is that of the following instruction, so following the return of the handler, the instruction is not retried. Or it could just kill the process, if there's no way to resolve the fault.
  • Faults, such as page faults and division by zero. These indicate an un-completable instruction. The pushed IP is that of the instruction generating the fault; the interrupt handler gets a chance to try to clear things up (most commonly, by paging in the memory page which led to the page fault), and then the instruction is retried.
  • Aborts, an unusual type of fault which is essentially unrecoverable (except by terminating the process). The interrupt handler should not return.

在被零除的情况下,恢复除法运算不是一个好的响应,因为这样一来,一条指令就被跳过了.实际上,这些更像是中止而不是错误.不应使用中断处理程序来破解替代行为".

In the case of division by zero, resuming following the division isn't a good response, because then an instruction has been skipped. Really, these are more like aborts than faults. The interrupt handler should not be used to hack in "alternative behavior".

这篇关于ISR之后,程序将继续返回同一行.(程序集8086)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆