Chinaunix首页 | 论坛 | 博客
  • 博客访问: 468150
  • 博文数量: 62
  • 博客积分: 1742
  • 博客等级: 中尉
  • 技术积分: 859
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-06 00:13
个人简介

这是一句很长很长而且又很啰嗦并且很无聊的废话...

文章分类

全部博文(62)

文章存档

2013年(1)

2012年(13)

2011年(48)

分类: LINUX

2011-04-30 21:35:23

  1. assume cs:codesg,ds:datasg,ss:stacksg
  2. datasg segment
  3. db 2h ;绿色 ;0h
  4. db 24h ;绿底红色 ;1h
  5. db 71h ;白底蓝色 ;2h
  6. db 'welcome to masm!',0 ;text ;3h
  7. db 16 dup(0) ;14h
  8. db '1975','1976','1977','1978','1979','1980','1981','1982','1983','1984','1985','1986','1987','1988','1989','1990','1991','1992','1993','1994','1995' ;24h
  9. dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514,345980,590827,803530,1183000,1843000,2759000,3753000,4649000,5937000 ;78h
  10. dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226,11542,14430,15257,17800 ;0cch
  11. db 64 dup(0) ;字缓冲 ;0f6h
  12. year_addr db '05'
  13. db '/'
  14. month_addr db '12'
  15. db '/'
  16. day_addr db '12'
  17. db ' '
  18. hour_addr db '08'
  19. db ':'
  20. minute_addr db '08'
  21. db ':'
  22. second_addr db '56',0
  23. datasg ends
  24. table segment
  25. dd 21 dup (0,0,0,0)
  26. table ends
  27. stacksg segment
  28. dd 16 dup (0)
  29. stacksg ends
  30. codesg segment
  31. ;--------------------------------------------------------showStr-------------------------------------------------------------------------------
  32. showStr:push bp;(byte->height(+9h)_byte->width(+8h),byte_byte->color(+6h),word->text_addr(+4h))(无返回,已恢复栈)
  33. mov bp,sp
  34. push ax
  35. push bx
  36. push cx
  37. push dx
  38. push di
  39. push si
  40. push es
  41. ;计算所在行数
  42. mov al,ss:9h[bp];获取行数
  43. mov bl,160;每行160个字节
  44. mul bl;行数x每行字节数
  45. push ax;保存下结果
  46. ;计算所在列数
  47. mov al,ss:8h[bp];获取列数
  48. mov bl,2h;你懂的...
  49. mul bl;
  50. pop bx
  51. add ax,bx;定位显存位置
  52. mov si,ax;保存一下
  53. ;显示
  54. mov di,0
  55. mov bx,ss:4h[bp]
  56. mov ax,0b800h
  57. mov es,ax
  58. for1:mov cl,ds:[bx][di];循环每个字符,复制到显示缓冲区,并加上色
  59. mov ch,0
  60. jcxz return
  61. mov byte ptr es:[si],cl;复制字符
  62. inc si
  63. mov ch,ss:6h[bp];获取颜色参数
  64. mov byte ptr es:[si],ch;设置颜色
  65. inc si
  66. inc di
  67. loop for1
  68. return:pop ax
  69. mov es,ax
  70. pop si
  71. pop di
  72. pop dx
  73. pop cx
  74. pop bx
  75. pop ax
  76. pop bp
  77. ret 6h
  78. ;--------------------------------------------------------showStr-------------------------------------------------------------------------------
  79. ;--------------------------------------------------------divdw---------------------------------------------------------------------------------
  80. divdw:push bp;(word->dividl(+8h),word->dividh(+6h),word->divish(+4h))(有返回(pop(+4h余),pop(+6h结果高位),pop(+8h结果低位)),自行恢复栈)
  81. mov bp,sp
  82. push ax
  83. push bx
  84. push cx
  85. push dx
  86. mov dx,0
  87. mov ax,ss:6h[bp]
  88. div word ptr ss:4h[bp]
  89. mov word ptr ss:6h[bp],ax;32位结果的高位
  90. mov ax,word ptr ss:8h[bp]
  91. div word ptr ss:4h[bp];欧几里德同余公式,被搞死...郁闷
  92. mov word ptr ss:8h[bp],ax;32位结果的底位
  93. mov word ptr ss:4h[bp],dx;32位结果的余
  94. pop dx
  95. pop cx
  96. pop bx
  97. pop ax
  98. pop bp
  99. ret
  100. ;--------------------------------------------------------divdw---------------------------------------------------------------------------------
  101. ;--------------------------------------------------------dtoc----------------------------------------------------------------------------------
  102. dtoc:push bp;(word->numl(+8h),word->numh(+6h),word->txt_addr(+4h))(无返回,已恢复栈)
  103. mov bp,sp
  104. push di
  105. push ax
  106. push dx
  107. push bx
  108. push cx
  109. push si
  110. mov si,0;转换计数
  111. mov di,ss:4h[bp];获取存放字符串的地址
  112. mov ax,ss:8h[bp];获取被除数低位
  113. push ax
  114. mov ax,ss:6h[bp];获取被除数高位
  115. push ax
  116. mov ax,10;设置除数
  117. push ax
  118. call divdw
  119. pop cx
  120. pop dx
  121. pop ax
  122. jmp dtoc_go
  123. dtoc_to:push ax
  124. push dx
  125. mov ax,10
  126. push ax
  127. call divdw
  128. pop cx
  129. pop dx
  130. pop ax
  131. dtoc_go:add cx,30h;数字转字符
  132. push cx;保存结果
  133. inc si
  134. mov cx,ax;先检查结果的低位等不等于0
  135. jcxz dtoc_ch;如果等于转到dtoc_ch检查高位
  136. jmp dtoc_to;否则继续转换
  137. dtoc_ch:mov cx,dx;检查高位等不等于0
  138. jcxz dtoc_fl;高位和低位都为0,除完...你懂的
  139. jmp dtoc_to;不用看了,继续转吧...
  140. dtoc_fl:mov cx,si
  141. jcxz dtoc_f
  142. dtoc_l1:pop ax
  143. mov ds:[di],al;设置正确结果
  144. inc di
  145. loop dtoc_l1
  146. dtoc_f:pop si
  147. pop cx
  148. pop bx
  149. pop dx
  150. pop ax
  151. pop di
  152. pop bp
  153. ret 6h
  154. ;--------------------------------------------------------dtoc----------------------------------------------------------------------------------
  155. ;--------------------------------------------------------gettime-------------------------------------------------------------------------------
  156. gettime:push bp;(word->prot(+6h),word->txt_addr(+4h))(无返回,已恢复栈)
  157. mov bp,sp
  158. push ax
  159. push si
  160. mov al,ss:6h[bp]
  161. out 70h,al
  162. in al,71h
  163. mov bl,al
  164. mov cl,4
  165. shr al,cl
  166. add al,30h
  167. mov si,ss:4h[bp]
  168. mov ds:[si],al
  169. and bl,00001111b
  170. add bl,30h
  171. mov ds:[si+1],bl
  172. pop si
  173. pop ax
  174. pop bp
  175. ret 4
  176. ;--------------------------------------------------------gettime-------------------------------------------------------------------------------
  177. start:mov ax,datasg
  178. mov ds,ax
  179. mov ax,stacksg
  180. mov ss,ax
  181. mov sp,40h
  182. show_t:mov ax,09h;年
  183. push ax
  184. mov ax,offset year_addr
  185. push ax
  186. call gettime
  187. mov ax,08h;月
  188. push ax
  189. mov ax,offset month_addr
  190. push ax
  191. call gettime
  192. mov ax,07h;日
  193. push ax
  194. mov ax,offset day_addr
  195. push ax
  196. call gettime
  197. mov ax,04h;时
  198. push ax
  199. mov ax,offset hour_addr
  200. push ax
  201. call gettime
  202. mov ax,02h;分
  203. push ax
  204. mov ax,offset minute_addr
  205. push ax
  206. call gettime
  207. mov ax,00h;秒
  208. push ax
  209. mov ax,offset second_addr
  210. push ax
  211. call gettime
  212. mov ah,20
  213. mov al,30
  214. push ax
  215. mov ah,0
  216. mov al,0fh
  217. push ax
  218. mov ax,offset year_addr
  219. push ax
  220. call showStr;
  221. jmp show_t
  222. game_o:mov ax,4c00h
  223. int 21h
  224. codesg ends
  225. end start
阅读(2013) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~