Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .386p
  2. sseg segment stack use16 'STACK'
  3. db 64 dup(?)
  4. sseg ends
  5. dseg segment para public use16 'DATA'
  6. tab label byte
  7. db 59
  8. dw offset cseg: f1Pressed
  9. db 71
  10. dw offset cseg: homePressed
  11. db 72
  12. dw offset cseg: upPressed
  13. db 73
  14. dw offset cseg: pageUpPressed
  15. db 75
  16. dw offset cseg: leftPressed
  17. db 77
  18. dw offset cseg: rightPressed
  19. db 79
  20. dw offset cseg: endPressed
  21. db 80
  22. dw offset cseg: downPressed
  23. db 81
  24. dw offset cseg: pageDownPressed
  25. db 0
  26. f1Str db 'f1$'
  27. homeStr db 'home$'
  28. upStr db 'up$'
  29. pUpStr db 'page up$'
  30. leftStr db 'left$'
  31. rghtStr db 'right$'
  32. endStr db 'end$'
  33. downStr db 'down$'
  34. pDwnStr db 'page down$'
  35. dseg ends
  36. cseg segment para public use16 'CODE'
  37. assume cs:cseg, ds:dseg, ss:sseg
  38. main proc far
  39. push ds
  40. push 0
  41. mov ax, dseg
  42. mov ds, ax
  43. call input
  44. ret
  45. main endp
  46. input proc near
  47. push ax
  48. push bx
  49. push cx
  50. push dx
  51. mov ah, 15
  52. int 10h
  53. mov ah, 0
  54. mov al, 2
  55. int 10h
  56. top:
  57. mov dx, 0
  58. mov al, 201
  59. mov cx, 1
  60. call print
  61. mov dl, 1
  62. mov al, 205
  63. mov cx, 78
  64. call print
  65. mov dl, 79
  66. mov al, 187
  67. mov cx, 1
  68. call print
  69. mov dh, 1
  70. mov al, 186
  71. mov cx, 1
  72. sides:
  73. mov dl, 0
  74. call print
  75. mov dl, 79
  76. call print
  77. inc dh
  78. cmp dh, 24
  79. jl sides
  80. bottom:
  81. mov dh, 24
  82. mov dl, 0
  83. mov al, 200
  84. mov cx, 1
  85. call print
  86. mov dl, 1
  87. mov al, 205
  88. mov cx, 78
  89. call print
  90. mov dl, 79
  91. mov al, 188
  92. mov cx, 1
  93. call print
  94. mov dx, 0101h
  95. mov ah, 2
  96. int 10h
  97. inputLoop:
  98. mov ah, 0
  99. int 16h
  100. cmp al, 0
  101. je key
  102. cmp al, 113
  103. je return
  104. call colorPrint
  105. jmp inputLoop
  106. key:
  107. lea bx, tab
  108. keyLoop:
  109. cmp byte ptr[bx], 0
  110. je unknownButton
  111. cmp ah, [bx]
  112. je printButton
  113. add bx, 3
  114. jmp keyLoop
  115. printButton:
  116. inc bx
  117. call word ptr[bx]
  118. jmp inputLoop
  119. unknownButton:
  120. mov al, 63
  121. call colorPrint
  122. jmp inputLoop
  123. return:
  124. pop dx
  125. pop cx
  126. pop bx
  127. pop ax
  128. ret
  129. input endp
  130. print proc near
  131. push bx
  132. push cx
  133. jmp print_
  134. printNewLine:
  135. inc dh
  136. mov dl, 1
  137. mov ah, 2
  138. int 10h
  139. print_:
  140. mov ah, 2
  141. int 10h
  142. mov ah, 10
  143. int 10h
  144. inc dl
  145. cmp dl, 79
  146. je printNewLine
  147. mov ah, 2
  148. int 10h
  149. pop cx
  150. pop bx
  151. ret
  152. print endp
  153. colorPrint proc near
  154. push bx
  155. jmp colorPrint_
  156. colorPrintNewLine:
  157. inc dh
  158. mov dl, 1
  159. mov ah, 2
  160. int 10h
  161. cmp dh, 24
  162. je colorPrintResetCursor
  163. jmp colorPrintExit
  164. colorPrintResetCursor:
  165. mov dx, 0101h
  166. mov ah, 2
  167. int 10h
  168. jmp colorPrintExit
  169. colorPrint_:
  170. mov ah, 2
  171. int 10h
  172. mov bl, 5fh
  173. mov ah, 9
  174. int 10h
  175. inc dl
  176. cmp dl, 79
  177. je colorPrintNewLine
  178. mov ah, 2
  179. int 10h
  180. colorPrintExit:
  181. pop bx
  182. ret
  183. colorPrint endp
  184. f1Pressed proc near
  185. lea bx, f1Str
  186. f1PressedLoop:
  187. mov al, byte ptr [bx]
  188. call colorPrint
  189. inc bx
  190. cmp byte ptr [bx], 36
  191. jne f1PressedLoop
  192. ret
  193. f1Pressed endp
  194. homePressed proc near
  195. lea bx, homeStr
  196. homePressedLoop:
  197. mov al, byte ptr [bx]
  198. call colorPrint
  199. inc bx
  200. cmp byte ptr [bx], 36
  201. jne homePressedLoop
  202. ret
  203. homePressed endp
  204. upPressed proc near
  205. lea bx, upStr
  206. upPressedLoop:
  207. mov al, byte ptr [bx]
  208. call colorPrint
  209. inc bx
  210. cmp byte ptr [bx], 36
  211. jne upPressedLoop
  212. ret
  213. upPressed endp
  214. pageUpPressed proc near
  215. lea bx, pUpStr
  216. pageUpPressedLoop:
  217. mov al, byte ptr [bx]
  218. call colorPrint
  219. inc bx
  220. cmp byte ptr [bx], 36
  221. jne pageUpPressedLoop
  222. ret
  223. pageUpPressed endp
  224. leftPressed proc near
  225. lea bx, leftStr
  226. leftPressedLoop:
  227. mov al, byte ptr [bx]
  228. call colorPrint
  229. inc bx
  230. cmp byte ptr [bx], 36
  231. jne leftPressedLoop
  232. ret
  233. leftPressed endp
  234. rightPressed proc near
  235. lea bx, rghtStr
  236. rightPressedLoop:
  237. mov al, byte ptr [bx]
  238. call colorPrint
  239. inc bx
  240. cmp byte ptr [bx], 36
  241. jne rightPressedLoop
  242. ret
  243. rightPressed endp
  244. endPressed proc near
  245. lea bx, endStr
  246. endPressedLoop:
  247. mov al, byte ptr [bx]
  248. call colorPrint
  249. inc bx
  250. cmp byte ptr [bx], 36
  251. jne endPressedLoop
  252. ret
  253. endPressed endp
  254. downPressed proc near
  255. lea bx, downStr
  256. downPressedLoop:
  257. mov al, byte ptr [bx]
  258. call colorPrint
  259. inc bx
  260. cmp byte ptr [bx], 36
  261. jne downPressedLoop
  262. ret
  263. downPressed endp
  264. pageDownPressed proc near
  265. lea bx, pDwnStr
  266. pageDownPressedLoop:
  267. mov al, byte ptr [bx]
  268. call colorPrint
  269. inc bx
  270. cmp byte ptr [bx], 36
  271. jne pageDownPressedLoop
  272. ret
  273. pageDownPressed endp
  274. cseg ends
  275. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement