WEB开发网
开发学院软件开发汇编语言 汇编源码系列之brk2 阅读

汇编源码系列之brk2

 2008-04-29 09:34:28 来源:WEB开发网   
核心提示:这个都是过去DOS时代的汇编源码,虽然已经过去了,汇编源码系列之brk2,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究.......

TITLE  BRK2 -- Break Handling Utilities Module
TRUE      EQU   01H           ;boolean true
FALSE      EQU   00H           ;boolean false
BREAKINT    EQU   23H           ;dos control-break intrpt
GETVECTOR    EQU   35H           ;dos get vector function
SETVECTOR    EQU   25H           ;dos set vector function
DOS_FUNCTION  EQU   21H           ;dos function call
BREAK      SEGMENT PUBLIC 'CODE'
BREAKFLAG    DB   0H           ;break key hit flag
SAVEBRK     DD   0H           ;saved break vec. contents
        ASSUME CS:BREAK
        ASSUME DS:NOTHING
;CHECK_BREAK  checks if ctrl-break has been pressed. It returns
;true if ctrl-break has been pressed and false if it hasn't.
        PUBLIC CHECK_BREAK
CHECK_BREAK   PROC  FAR
        XOR   AX, AX         ;clear ax
        MOV   AL, BREAKFLAG      ;return value = breakflag
        MOV   BREAKFLAG, FALSE    ;reset breakflag
        RET
CHECK_BREAK   ENDP
;INSTALL_BREAK_HANDLER sets up a ctrl-break interrupt handler. It
;also saves the address of the former break handler so that it can
;be restored later.
        PUBLIC INST_BRK_HANDLR
INST_BRK_HANDLR PROC  FAR
        PUSH  DS
        MOV   AL, BREAKINT      ;AL = break interrupt
        MOV   AH, GETVECTOR      ;AH = dos function code
        INT   DOS_FUNCTION      ;call dos
        MOV   WORD PTR SAVEBRK, BX  ;save offset in int vector
        MOV   WORD PTR SAVEBRK+2, ES ;save base in int vector
        MOV   AL, BREAKINT      ;AL = break interrupt
        MOV   AH, SETVECTOR      ;AH = dos function code
        MOV   DX, OFFSET BRK_HANDLER ;DX = offset of brk handler
        MOV   BX, CS         ;BX = this segment
        MOV   DS, BX         ;DS = this segment
        INT   DOS_FUNCTION      ;call dos
        POP   DS
        RET
INST_BRK_HANDLR ENDP
;BRK_HANDLER  is invoked by the bios when ctrl_break is pressed
BRK_HANDLER   PROC  FAR
        MOV   BREAKFLAG, TRUE     ;breakflag = yes, break hit
        IRET
BRK_HANDLER   ENDP
;REMOVE_BREAK_HANDLER restores the previous ctrl-break handler
REM_BRK_HANDLR PROC  FAR
        PUSH  DS
        MOV   AL, BREAKINT      ;AL = break interrupt
        MOV   AH, SETVECTOR      ;AH = dos function code
        MOV   DX, WORD PTR SAVEBRK  ;DX = saved 1st word
        MOV   BX, WORD PTR SAVEBRK+2 ;BX = saved 2nd word
        MOV   DS, BX         ;DS = saved 2nd word
        INT   DOS_FUNCTION      ;call dos
        POP   DS
        RET
REM_BRK_HANDLR ENDP
BREAK      ENDS
        END


Tags:汇编 源码 系列

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接