Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. .model tiny
  2. .code
  3. .386
  4. org 100h
  5. entry: jmp start
  6. int9:
  7. in al, 60h
  8.  
  9. mov di, tail
  10. mov buffer[di], al
  11.  
  12. inc tail
  13. and tail, 0fh
  14.  
  15. mov ax, tail
  16. cmp head, ax
  17.  
  18. jne _1
  19.  
  20. inc head
  21. and head, 0fh
  22.  
  23. _1:
  24. in al, 61h
  25. or al, 80h
  26. out 61h, al
  27.  
  28. and al, 07fh
  29. out 61h, al
  30.  
  31. mov al, 20h
  32. out 20h, al
  33. iret
  34.  
  35. buffer db 10h dup (?)
  36. head dw ?
  37. tail dw ?
  38. oldInt9 dd ?
  39. ENDL db 13, 10, '$'
  40. ESC_SC db 81h
  41. SPACE_SC db 039h
  42. spaceMessage db 'muhaha', '$'
  43.  
  44. start:
  45. xor dx, dx
  46. mov ax, 3509h
  47. int 21h
  48. mov word ptr oldInt9, bx
  49. mov word ptr oldInt9+2, es
  50.  
  51. cli
  52. mov ax, 2509h
  53. mov dx, offset int9
  54. int 21h
  55. sti
  56.  
  57. _2:
  58. mov di, head
  59. cmp tail, di
  60. je _2
  61.  
  62. mov dl, buffer[di]
  63. inc head
  64. and head, 0fh
  65.  
  66. cmp dl, SPACE_SC
  67. jne _cont
  68.  
  69. mov ax, 0900h
  70. lea dx, spaceMessage
  71. int 21h
  72.  
  73. mov ax, 0900h
  74. lea dx, ENDL
  75. int 21h
  76.  
  77. _cont:
  78.  
  79. cmp dl, ESC_SC
  80. je exit
  81.  
  82. xor bx, bx
  83. mov bl, dl
  84. call out_hex
  85. jne _2
  86.  
  87. out_hex proc
  88. push bp
  89. mov bp, sp
  90.  
  91. pusha
  92.  
  93. mov cx, 4
  94. _3:
  95. rol bx, 4
  96. mov al, bl
  97. and al, 0fh
  98. cmp al, 10
  99. sbb al, 69h
  100. das
  101.  
  102. mov dh, 02h
  103. xchg ax, dx
  104. int 21h
  105. loop _3
  106.  
  107. mov ax, 0900h
  108. lea dx, ENDL
  109. int 21h
  110.  
  111. popa
  112.  
  113. mov sp, bp
  114. pop bp
  115. ret
  116. out_hex endp
  117.  
  118. exit:
  119. cli
  120. mov ax, 2509h
  121. mov dx, word ptr cs:[oldInt9]
  122. mov ds, word ptr cs:[oldInt9+2]
  123. int 21h
  124. sti
  125. ret
  126.  
  127. end entry
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement