Chinaunix首页 | 论坛 | 博客
  • 博客访问: 127439
  • 博文数量: 30
  • 博客积分: 972
  • 博客等级: 中士
  • 技术积分: 332
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-08 10:04
文章分类

全部博文(30)

文章存档

2012年(30)

分类: 服务器与存储

2012-07-07 11:13:48


点击(此处)折叠或打开

  1. assume cs:code
  2. stack segment
  3. db 128 dup (0);定义堆栈区为128字节
  4. stack ends
  5. data segment
  6. db 0,0;定义2字节的数据段
  7. data ends
  8. code segment
  9. start:
  10. mov ax,stack
  11. mov ss,ax
  12. mov sp,128;设置堆栈及SP指针
  13. mov ax,data
  14. mov ds,ax;设置数据段DS
  15. mov ax,0
  16. mov es,ax;设置DS段
  17. push es:[9*4]
  18. pop ds:[0]
  19. push es:[9*4+2]
  20. pop ds:[2];将int9中断例程保存到ds[0],ds[2]
  21. mov word ptr es:[9*4],offset int9;word ptr为字节强制转换
  22. mov es:[9*4+2],cs;修改int9中断向量
  23. mov ax,0b800h
  24. mov es,ax
  25. mov ah,'a'
  26. s: mov es:[160*12+40*2],ah
  27. call delay
  28. inc ah
  29. cmp ah,'z'
  30. jna s;在屏幕上打印'a'~'z'
  31. mov ax,0
  32. mov es,ax
  33. push ds:[0]
  34. pop es:[9*4]
  35. push ds:[2]
  36. pop es:[9*4+2];修改回原来的int9中断例程
  37. mov ah,4ch
  38. mov al,00h
  39. int 21h;调用21号中断4c子程序,返回DOS。
  40. delay:
  41. push ax
  42. push dx
  43. mov dx,5000h
  44. mov ax,00h
  45. s1: sub ax,1h
  46. sbb dx,0h
  47. cmp ax,0h
  48. jne s1
  49. cmp dx,00h
  50. jne s1
  51. pop dx
  52. pop ax
  53. ret;延迟5000*16*FFFF个机器指令周期
  54. int9:
  55. push ax
  56. push bx
  57. push es;保存ax,bx,es
  58. in al,60h;读取60H端口的内容,即检测键盘输入中断信息
  59. pushf
  60. call dword ptr ds:[0]
  61. cmp al,01h;比较是否按下ESC键
  62. jne int9ret
  63. mov ax,0b800h
  64. mov es,ax
  65. inc byte ptr es:[160*12+40*2+1];更改字符的显示属性
  66. int9ret:
  67. pop es
  68. pop bx
  69. pop ax
  70. iret;不是ESC键就弹出堆栈,释放站空间
  71. code ends
  72. end start

阅读(2511) | 评论(0) | 转发(1) |
0

上一篇:黑白棋游戏

下一篇:并发Web服务器

给主人留下些什么吧!~~