鸿 网 互 联 www.68idc.cn

王爽<汇编语言> 第十六章 实验十六

来源:互联网 作者:佚名 时间:2015-08-13 07:41
assume cs:codesg,ss:stacksg stacksg segment db 128 dup(0) stacksg ends codesg segment int7ch_start:jmp int_main ;-----------------------------------------清空屏幕 ck:push bx push cx push es mov bx,0b800h mov es,bx mov bx,0 mov cx,2000 ck_s
  1. assume cs:codesg,ss:stacksg
  2. stacksg segment
  3. db 128 dup(0)
  4. stacksg ends
  5. codesg segment
  6. int7ch_start:jmp int_main
  7. ;-----------------------------------------清空屏幕
  8. ck:push bx
  9. push cx
  10. push es
  11. mov bx,0b800h
  12. mov es,bx
  13. mov bx,0
  14. mov cx,2000
  15. ck_s:mov byte ptr es:[bx],' ';清空屏幕
  16. add bx,2
  17. loop ck_s
  18. pop es
  19. pop cx
  20. pop bx
  21. ret
  22. ;-----------------------------------------设置前景
  23. qj:push bp
  24. mov bp,sp
  25. push ax
  26. push cx
  27. push bx
  28. push es
  29. cmp byte ptr ss:4h[bp],7h;颜色值大于7就不干...
  30. ja qj_e
  31. mov ax,0b800h
  32. mov es,ax
  33. mov ax,ss:4h[bp]
  34. mov bx,1
  35. mov cx,2000
  36. qj_s:and byte ptr es:[bx],11111000b;前景色置0
  37. or byte ptr es:[bx],al;设置前景色
  38. add bx,2h
  39. loop qj_s
  40. qj_e:pop es
  41. pop bx
  42. pop cx
  43. pop ax
  44. pop bp
  45. ret
  46. ;-----------------------------------------设置背景
  47. bj:push bp
  48. mov bp,sp
  49. push ax
  50. push cx
  51. push bx
  52. push es
  53. cmp byte ptr ss:4h[bp],7h;颜色值大于7就不干...
  54. ja bj_e
  55. mov ax,0b800h
  56. mov es,ax
  57. mov ax,ss:4h[bp]
  58. mov cl,4
  59. shl al,cl;左移4位
  60. mov bx,1
  61. mov cx,2000
  62. bj_s:and byte ptr es:[bx],10001111b;背景色置0
  63. or byte ptr es:[bx],al;设置背景色
  64. add bx,2h
  65. loop bj_s
  66. bj_e:pop es
  67. pop bx
  68. pop cx
  69. pop ax
  70. pop bp
  71. ret
  72. ;-----------------------------------------滚动一行
  73. gd:push ds
  74. push es
  75. push si
  76. push di
  77. push cx
  78. push ax
  79. mov ax,0b800h
  80. mov es,ax
  81. mov di,0
  82. mov ds,ax
  83. mov si,160
  84. cld;递增
  85. mov cx,24
  86. gd_s:push cx
  87. push si
  88. push di
  89. mov cx,160
  90. rep movsb;复制
  91. pop di
  92. pop si
  93. add di,160
  94. add si,160
  95. pop cx
  96. loop gd_s
  97. pop ax
  98. pop cx
  99. pop di
  100. pop si
  101. pop es
  102. pop ds
  103. ret
  104. int_main:jmp codemain
  105. fun_table dw ck-int7ch_start,qj-int7ch_start,bj-int7ch_start,gd-int7ch_start;功能列表(数据标号,因为地址在编译时固定了,所以只能拿偏移了...)
  106. codemain:push di;ax是参数ah功能号al是颜色参数
  107. push bx
  108. push si
  109. cmp ah,3;检查非法操作
  110. ja int7ch_o
  111. mov bx,0
  112. mov bl,ah
  113. add bx,bx
  114. mov si,bx;获取功能号
  115. mov bx,fun_table-int7ch_start
  116. mov bx,cs:200h[bx][si];获取功能地址
  117. add bx,200h;
  118. push ax
  119. call bx
  120. pop ax
  121. int7ch_o:pop si
  122. pop bx
  123. pop di
  124. iret
  125. int7ch_end:nop
  126. start:mov ax,stacksg
  127. mov ss,ax
  128. mov sp,128
  129. mov ax,cs;复制代码
  130. mov ds,ax
  131. mov ax,0
  132. mov es,ax
  133. mov si,offset int7ch_start
  134. mov di,200h
  135. mov cx,offset int7ch_end-offset int7ch_start
  136. rep movsb
  137. mov ax,0;安装7ch中断例程
  138. mov es,ax
  139. mov word ptr es:[7ch*4],200h
  140. mov word ptr es:[7ch*4+2],0h
  141. mov ah,2;功能(0,1,2,3)
  142. mov al,2;颜色(0,1,2,3,4,5,6,7)
  143. int 7ch;调用
  144. mov ax,4c00h
  145. int 21h
  146. codesg ends
  147. end start
网友评论
<