【问题标题】:What is int 10 doing in assembly?int 10 在汇编中做什么?
【发布时间】:2020-01-07 01:13:37
【问题描述】:

我正在为学校学习汇编,示例代码开头有这部分:

mov al, 0
mov ah, 5
int 10

在此之前有一个程序:

.386
instructions SEGMENT use16
        ASSUME  CS:instructions

interrupt_handler PROC
; some code
interrupt_handler ENDP

int 10 行在做什么?是调用interrupt_handler 程序吗?为什么正好是 10?

这一切都在 DoSBox 中运行,并使用 masm 组装。

【问题讨论】:

    标签: assembly interrupt dos masm x86-16


    【解决方案1】:

    我发现似乎是 OP 母语(波兰语)代码的完整副本。 https://ideone.com/fork/YQG7y 。有这段代码(通过谷歌翻译运行):

    ; ================================================= =======
    
    ; main program - installation and uninstallation of the procedure
    ; interrupt handling
    
    ; determining page number 0 for text mode
    start:
    mov al, 0
    mov ah, 5
    int 10
    

    从这段代码中可以清楚地看出这是一个错误。它应该是int 10h 而不是int 10(与int 0ah 相同)。 int 10h 记录为:

    VIDEO - SELECT ACTIVE DISPLAY PAGE
    AH = 05h
    AL = new page number (00h to number of pages - 1) (see #00010)
    
    Return:
    Nothing
    
    Desc: Specify which of possibly multiple display pages will be visible
    

    int 10 完全不同:

    IRQ2 - LPT2 (PC), VERTICAL RETRACE INTERRUPT (EGA,VGA)
    

    从程序的角度来看,使用int 10 调用 IRQ2 中断处理程序实际上不会做任何事情。由于默认文本页面可能已经为 0,因此程序按预期运行。


    正确的代码:

    mov al, 0
    mov ah, 5
    int 10h
    

    将使用 BIOS 服务 10h 功能 5 将文本模式显示页面设置为 0。

    【讨论】:

      【解决方案2】:

      简单的答案是int 10h(我认为您的代码有错字)通常在提供视频服务的向量处调用实模式中断处理程序。 int 10h services 包括设置视频模式、字符和字符串输出以及图形基元(图形模式下读取和写入像素)。

      【讨论】:

      • 感谢您的回答!你有没有更详细的网站?对我来说仍然很困惑(例如,在向量上设置中断处理程序是什么意思)。
      • @WojtekWencel 是的,您可以在 Wikipedia en.wikipedia.org/wiki/INT_10H 中查看详细信息,DOS 中的所有中断列表 ablmcc.edu.hk/~scy/CIT/8086_bios_and_dos_interrupts.htm
      • 但是 wiki 页面是关于 INT 10H,而不是 INT 10。我一开始对此感到困惑,因为我发现的所有页面都提到了 10H,但是这个程序按预期运行和工作,所以这不是一个错字。
      • 相同是什么意思?不是 10h = 16
      猜你喜欢
      • 2013-12-28
      • 1970-01-01
      • 2014-06-24
      • 1970-01-01
      • 2010-11-19
      • 2011-09-11
      • 2015-01-20
      • 2014-11-08
      • 2016-04-02
      相关资源
      最近更新 更多