鱼C论坛

 找回密码
 立即注册
查看: 2120|回复: 3

汇编15章int9中断一个小疑问..求解释

[复制链接]
发表于 2012-7-26 02:00:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. assume cs:code
  2. stack segment
  3. db 128 dup(0)
  4. stack ends

  5. data segment

  6. dw 0,0

  7. data ends

  8. code segment

  9. dong:  mov ax,stack
  10.        mov ss,ax
  11.            mov sp,128
  12.           
  13.            mov ax,data
  14.            mov ds,ax
  15.           
  16.            mov ax,0
  17.            mov es,ax
  18.           
  19.            push es:[9*4]
  20.            pop ds:[0]
  21.            push es:[9*4+2]
  22.            pop ds:[2]
  23.           
  24.            mov word ptr es:[9*4],offset int9
  25.            mov es:[9*4+2],cs
  26.           
  27.            mov ax,0b800h
  28.            mov es,ax
  29.            mov ah,'a'
  30.            s:
  31.            mov es:[160*12+40*2],ah
  32.           
  33.            call delay
  34.            inc ah
  35.            cmp ah,'z'
  36.            jna s
  37.           
  38.            mov ax,0
  39.            mov es,ax
  40.           
  41.            push ds:[0]
  42.            pop es:[9*4]
  43.            push ds:[2]
  44.            pop es:[9*4+2]
  45.           
  46.            mov ax,4c00h
  47.            int 21h
  48.           
  49.            delay:
  50.            push ax
  51.            push dx
  52.            mov dx,1000h
  53.            mov ax,0
  54.            s1:
  55.            sub ax,1
  56.            sbb dx,0
  57.            cmp dx,0
  58.            jne s1
  59.           
  60.            pop dx
  61.            pop ax
  62.            ret
  63.           
  64.            int9:
  65.            push ax
  66.            push bx
  67.            push es
  68.           
  69.            in al,60h
  70.           
  71.            pushf
  72.            pushf
  73.            pop bx
  74.            and bh,11111100b
  75.            push bx
  76.            popf
  77.            call dword ptr ds:[0]
  78.           
  79.            cmp al,1
  80.            jne int9ret
  81.           
  82.            mov ax,0b800h
  83.            mov es,ax
  84.            inc byte ptr es:[160*12+40*2+1]
  85.           
  86.            int9ret:
  87.           
  88.            pop es
  89.            pop bx
  90.            pop ax
  91.            iret
  92.           
  93.            code ends
  94.            end dong
  95.           
  96.           
  97.           
  98.           
  99.           
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
 楼主| 发表于 2012-7-26 02:03:20 | 显示全部楼层
  1. 69.           int9:

  2. 70.           push ax

  3. 71.           push bx

  4. 72.           push es

  5. 73.           

  6. 74.           in al,60h

  7. 75.           

  8. 76.           pushf

  9. 77.           pushf

  10. 78.           pop bx

  11. 79.           and bh,11111100b

  12. 80.           push bx

  13. 81.           popf

  14. 82.           call dword ptr ds:[0]

  15. 83.           

  16. 84.           cmp al,1

  17. 85.           jne int9ret

  18. 86.           

  19. 87.           mov ax,0b800h

  20. 88.           mov es,ax

  21. 89.           inc byte ptr es:[160*12+40*2+1]

  22. 90.           

  23. 91.           int9ret:

  24. 92.           

  25. 93.           pop es

  26. 94.           pop bx

  27. 95.           pop ax

  28. 96.           iret

复制代码
主要是这里pushf标志寄存器进栈2次,却只出栈一次,那第一个压栈的标志寄存器,数据按思路屡下去就给了es,我尝试,只用一个pushf但是程序运行起来,得不到预期的效果,求解释。
小甲鱼最新课程 -> https://ilovefishc.com
 楼主| 发表于 2012-7-26 02:06:21 | 显示全部楼层
好像懂点了,自己捉摸着有点意思,坐等大侠指点。求验证,
我理解的思路是call dword ptr ds:[0] 在真实int9中断返回时,iret把我第一次压栈的标志寄存器的内容给popf出来了。

小甲鱼最新课程 -> https://ilovefishc.com
 楼主| 发表于 2012-7-26 02:06:52 | 显示全部楼层
坑爹的我,深更半夜自问自答。
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-1 15:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表