home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Shareware / Utilitare / emu / Emu8086_Setup_307c.exe / {app} / Samples / scroll.asm < prev    next >
Encoding:
Assembly Source File  |  2002-08-02  |  3.8 KB  |  179 lines

  1. ; This example shows the used of
  2. ; scrolling functions.
  3. ; It prints some test strings,
  4. ; and scrolls up/down the
  5. ; window at (1,1)-(8,5).
  6.  
  7. #make_COM#
  8.  
  9. ORG     100h
  10.  
  11. ; set data segment to code segment,
  12. ; (if not set already):
  13. PUSH    CS
  14. POP     DS
  15.  
  16. ; clear screen:
  17. CALL    clear_screen
  18.  
  19. ; print out the test
  20. ; strings:
  21. LEA     SI, s1
  22. CALL    print_string
  23.  
  24. ; print "Press any key to scroll up..."
  25. ; message:
  26. LEA     SI, msg1
  27. CALL    print_string
  28.  
  29. ; wait for any key:
  30. XOR     AX, AX
  31. INT     16h
  32.  
  33. ; scroll window up:
  34. MOV     AH, 06h ; scroll up function id.
  35. MOV     AL, 2   ; lines to scroll.
  36. MOV     BH, 07  ; attribute for new lines.
  37. MOV     CH, 1   ; upper row.
  38. MOV     CL, 1   ; upper col.
  39. MOV     DH, 5   ; lower row.
  40. MOV     DL, 8   ; lower col.
  41. INT     10h
  42.  
  43.  
  44. ; print "Press any key for next test..."
  45. ; message:
  46. LEA     SI, msg2
  47. CALL    print_string
  48.  
  49. ; wait for any key:
  50. XOR     AX, AX
  51. INT     16h
  52.  
  53. ; clear screen:
  54. CALL    clear_screen
  55.  
  56. ; print out the test
  57. ; strings:
  58. LEA     SI, s1
  59. CALL    print_string
  60.  
  61. ; print "Press any key to scroll down..."
  62. ; message:
  63. LEA     SI, msg3
  64. CALL    print_string
  65.  
  66. ; wait for any key:
  67. XOR     AX, AX
  68. INT     16h
  69.  
  70. ; scroll window down:
  71. MOV     AH, 07h ; scroll down function id.
  72. MOV     AL, 2   ; lines to scroll.
  73. MOV     BH, 07  ; attribute for new lines.
  74. MOV     CH, 1   ; upper row.
  75. MOV     CL, 1   ; upper col.
  76. MOV     DH, 5   ; lower row.
  77. MOV     DL, 8   ; lower col.
  78. INT     10h
  79.  
  80. ; print "That's it, press any key..."
  81. ; message:
  82. LEA     SI, msg4
  83. CALL    print_string
  84.  
  85. ; wait for any key:
  86. XOR     AX, AX
  87. INT     16h
  88.  
  89. RET     ; return to OS.
  90.  
  91. ;==============================
  92. ; procedure to clear the screen,
  93. ; (done by scrolling entire screen window),
  94. ; and set cursor position to top of it:
  95. clear_screen PROC NEAR
  96. PUSH    AX      ; store registers...
  97. PUSH    DS      ;
  98. PUSH    BX      ;
  99. PUSH    CX      ;
  100. PUSH    DI      ;
  101.  
  102. MOV     AX, 40h
  103. MOV     DS, AX  ; for getting screen parameters.
  104. MOV     AH, 06h ; scroll up function id.
  105. MOV     AL, 0   ; scroll all lines!
  106. MOV     BH, 07  ; attribute for new lines.
  107. MOV     CH, 0   ; upper row.
  108. MOV     CL, 0   ; upper col.
  109. MOV     DI, 84h ; rows on screen -1,
  110. MOV     DH, [DI] ; lower row (byte).
  111. MOV     DI, 4Ah ; columns on screen,
  112. MOV     DL, [DI]
  113. DEC     DL      ; lower col.
  114. INT     10h
  115.  
  116. ; set cursor position to top
  117. ; of the screen:
  118. MOV     BH, 0   ; current page.
  119. MOV     DL, 0   ; col.
  120. MOV     DH, 0   ; row.
  121. MOV     AH, 02
  122. INT     10h
  123.  
  124. POP     DI      ; re-store registers...
  125. POP     CX      ;
  126. POP     BX      ;
  127. POP     DS      ;
  128. POP     AX      ;
  129.  
  130. RET
  131. clear_screen ENDP
  132. ;==============================
  133.  
  134. ;==============================
  135. ; procedure to print a null terminated
  136. ; string at current cursor position,
  137. ; receives address of string in SI
  138. ; register:
  139. print_string PROC NEAR
  140. PUSH    AX      ; store registers...
  141. PUSH    SI      ;
  142.  
  143. next_char:      
  144.         MOV     AL, [SI]
  145.         CMP     AL, 0
  146.         JZ      printed
  147.         INC     SI
  148.         MOV     AH, 0Eh ; teletype function.
  149.         INT     10h
  150.         JMP     next_char
  151. printed:
  152.  
  153. POP     SI      ; re-store registers...
  154. POP     AX      ;
  155.  
  156. RET
  157. print_string ENDP
  158. ;==============================
  159.  
  160. ; test strings:
  161. s1 db '0000-A-0000000000', 13, 10
  162.    db '1111-B-1111111111', 13, 10
  163.    db '2222-C-2222222222', 13, 10
  164.    db '3333-D-3333333333', 13, 10
  165.    db '4444-E-4444444444', 13, 10
  166.    db '5555-F-5555555555', 13, 10
  167.    db '6666-G-6666666666', 13, 10
  168.    db '7777-H-7777777777', 13, 10, 0
  169.  
  170. msg1 db 'Press any key to scroll up...', 13, 10, 0
  171.  
  172. msg2 db 'Press any key for next test...', 13, 10, 0
  173.  
  174. msg3 db 'Press any key to scroll down...', 13, 10, 0
  175.  
  176. msg4 db 'That', 27h, 's it, press any key...', 13, 10, 0
  177.  
  178. END
  179.