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

📄 trick.asm

📁 内存驻留程序的基本思想就是让程序一直停留在内存中
💻 ASM
字号:
;---------------------------------------------------------
;   No matter you what chars you typed, the only words can
; be displayed is 'Kasi, haha!'
;
; By Kasi
; 2004.3.23
;---------------------------------------------------------
CSEG    SEGMENT
        ASSUME          CS:CSEG, DS:CSEG
        ORG             100H
Start:
        JMP             Initialize

old_keyboard_io DD      ?               ; Pointer of old INT 16H

Hello_Msg       DB      'Kasi, haha!'	; string to display when catch a key-press
Msg_Index       DW      0		; which char in the string been displayed(char index)

new_keyboard_io PROC    FAR
        ASSUME          CS:CSEG, DS:CSEG
                STI

                CMP     AH, 00H			; INT 16H - AH = 0 to catch
                JE      new_io_0		;   key-press func
;-------------------------------
;   In the DOS prompt(C:>), DOS uses 
; INT 16H - AH = 10H to get a char, not
; AH = 00H
                CMP     AH, 10H
                JE      new_io_0
;-------------------------------
                ASSUME  DS:nothing
                JMP     old_keyboard_io		; No catch, jump to old handler
new_io_0:
                PUSHF
        ASSUME          DS:nothing
                CALL    old_keyboard_io
                CMP     AL, 0DH			; Is a ENTER been pressed ?
                JNE     new_io_1		;   no, output string 'Kasi, haha!'
                MOV     Msg_Index, 0		;   yes, reset the string index
                JMP     new_io_done		;      and return
new_io_1:
                PUSH    SI
                MOV     SI, Msg_Index		; Get current char index
                MOV     AL, Hello_Msg[SI]	; Get current char

                INC     SI			; Next char in the Hello_Msg
                CMP     SI, 11			; Reach the end of the Hello_Msg ?
                JNE     new_io_2		;   no, jump
                MOV     SI, 0			;   yes, set the char index to the beginning
new_io_2:
                MOV     Msg_Index, SI		; Save the char index
                POP     SI
new_io_done:
                IRET
new_keyboard_io ENDP

Initialize:
        ASSUME          CS:CSEG, DS:CSEG
                MOV     BX, CS			; Initialize the 
                MOV     DS, BX			;   data segment
                MOV     AL, 16H			; Interrupt index in vector table
                MOV     AH, 35H			; Get the interrupt dealing
                INT     21H			;   program's pointer
                MOV     old_keyboard_io, BX	; offset
                MOV     old_keyboard_io[2], ES	; base address

                MOV     DX, OFFSET new_keyboard_io
                MOV     AL, 16H
                MOV     AH, 25H
                INT     21H

                MOV     DX, OFFSET Initialize
                INT     27H

CSEG    ENDS
        END     Start

⌨️ 快捷键说明

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