⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scroll.asm

📁 汇编语言 参考书 包含作业与答案 从入门到精通 通俗易懂
💻 ASM
字号:
; This example shows the used of
; scrolling functions.
; It prints some test strings,
; and scrolls up/down the
; window at (1,1)-(8,5).

#make_COM#

ORG     100h

; set data segment to code segment,
; (if not set already):
PUSH    CS
POP     DS

; clear screen:
CALL    clear_screen

; print out the test
; strings:
LEA     SI, s1
CALL    print_string

; print "Press any key to scroll up..."
; message:
LEA     SI, msg1
CALL    print_string

; wait for any key:
XOR     AX, AX
INT     16h

; scroll window up:
MOV     AH, 06h ; scroll up function id.
MOV     AL, 2   ; lines to scroll.
MOV     BH, 07  ; attribute for new lines.
MOV     CH, 1   ; upper row.
MOV     CL, 1   ; upper col.
MOV     DH, 5   ; lower row.
MOV     DL, 8   ; lower col.
INT     10h


; print "Press any key for next test..."
; message:
LEA     SI, msg2
CALL    print_string

; wait for any key:
XOR     AX, AX
INT     16h

; clear screen:
CALL    clear_screen

; print out the test
; strings:
LEA     SI, s1
CALL    print_string

; print "Press any key to scroll down..."
; message:
LEA     SI, msg3
CALL    print_string

; wait for any key:
XOR     AX, AX
INT     16h

; scroll window down:
MOV     AH, 07h ; scroll down function id.
MOV     AL, 2   ; lines to scroll.
MOV     BH, 07  ; attribute for new lines.
MOV     CH, 1   ; upper row.
MOV     CL, 1   ; upper col.
MOV     DH, 5   ; lower row.
MOV     DL, 8   ; lower col.
INT     10h

; print "That's it, press any key..."
; message:
LEA     SI, msg4
CALL    print_string

; wait for any key:
XOR     AX, AX
INT     16h

RET     ; return to OS.

;==============================
; procedure to clear the screen,
; (done by scrolling entire screen window),
; and set cursor position to top of it:
clear_screen PROC NEAR
PUSH    AX      ; store registers...
PUSH    DS      ;
PUSH    BX      ;
PUSH    CX      ;
PUSH    DI      ;

MOV     AX, 40h
MOV     DS, AX  ; for getting screen parameters.
MOV     AH, 06h ; scroll up function id.
MOV     AL, 0   ; scroll all lines!
MOV     BH, 07  ; attribute for new lines.
MOV     CH, 0   ; upper row.
MOV     CL, 0   ; upper col.
MOV     DI, 84h ; rows on screen -1,
MOV     DH, [DI] ; lower row (byte).
MOV     DI, 4Ah ; columns on screen,
MOV     DL, [DI]
DEC     DL      ; lower col.
INT     10h

; set cursor position to top
; of the screen:
MOV     BH, 0   ; current page.
MOV     DL, 0   ; col.
MOV     DH, 0   ; row.
MOV     AH, 02
INT     10h

POP     DI      ; re-store registers...
POP     CX      ;
POP     BX      ;
POP     DS      ;
POP     AX      ;

RET
clear_screen ENDP
;==============================

;==============================
; procedure to print a null terminated
; string at current cursor position,
; receives address of string in SI
; register:
print_string PROC NEAR
PUSH    AX      ; store registers...
PUSH    SI      ;

next_char:      
        MOV     AL, [SI]
        CMP     AL, 0
        JZ      printed
        INC     SI
        MOV     AH, 0Eh ; teletype function.
        INT     10h
        JMP     next_char
printed:

POP     SI      ; re-store registers...
POP     AX      ;

RET
print_string ENDP
;==============================

; test strings:
s1 db '0000-A-0000000000', 13, 10
   db '1111-B-1111111111', 13, 10
   db '2222-C-2222222222', 13, 10
   db '3333-D-3333333333', 13, 10
   db '4444-E-4444444444', 13, 10
   db '5555-F-5555555555', 13, 10
   db '6666-G-6666666666', 13, 10
   db '7777-H-7777777777', 13, 10, 0

msg1 db 'Press any key to scroll up...', 13, 10, 0

msg2 db 'Press any key for next test...', 13, 10, 0

msg3 db 'Press any key to scroll down...', 13, 10, 0

msg4 db 'That', 27h, 's it, press any key...', 13, 10, 0

END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -