Files
FCDOSrenew/source/fcquit.asm
2026-02-11 11:09:14 +08:00

137 lines
4.9 KiB
NASM
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;PS: File Save with UFT-8==========================================================
; FCDOS - Free Chinese DOS
; fcquit.asm (卸载驻留模块)
;--------------------------------------------------------------------------------
; 原始信息:
; 原始代码发布于:
; https://www.cn-dos.net/forum/viewthread.php?tid=24334&fpage=1
; 作者:
; Macadd <macadd@163.com>
; 中国DOS联盟论坛 https://www.cn-dos.net/forum/viewpro.php?uid=58572
;
; https://sourceforge.net/projects/fcdos/
; 作者:
; fc_lijian <fc_lijian@users.sourceforge.net>
;
; 原始版本v1.1.0
; 许可证:
; https://www.cn-dos.net/forum/post.php?action=reply&fid=17&tid=24334&repquote=154336
; Macadd都是汇编写的COM文件文件不大在DOS下用DEBUG看就可以了。 2006-11-27 09:37
;--------------------------------------------------------------------------------
; 版本:重构版 v1.0
; 版权所有 (c) fc_lijian@users.sourceforge.net
; 重构版本 (c) 2026 Tarime Argus
;
; 本文件是FCDOS项目的汇编源码重构版。
; 原始只有二进制COM文件现通过反汇编恢复为可维护的汇编代码。
; 本项目基于开源原则发布,具体许可证遵循原始项目。
;
; 功能退出FCDOS中文平台清除驻留状态。
; 使用fcquit.com
;
; 修改历史:
; 2026-01-08 Tarime Argus 初始版本
; 2026-02-05 Tarime Argus Ver. 1.0
;================================================================================
;FCQUIT.COM renew by Tarime Argus 2026-02-05 Ver. 1.0
;Compile with JWasm v2.20
;COMMAND: jwasmd -bin -Fo FCQUIT.COM fcquit.asm
.286
.model tiny
DOSint_PrintString MACRO printString
MOV DX, offset printString
call dosint2109h
ENDM DOSint_PrintString
.code
org 100h
start:
MOV AX,CS ;初始化数据段
MOV DS,AX
;检查中断向量非空
Check_INT80h:
MOV AX,3580h ;检查80h中断
INT 21h
MOV AX,ES ;检查中断向量是否为空
AND AX,BX
JZ Error_KNL_Not_Found ;向量空则进入错误处理
;--------
MOV AX,8000h
INT 80h ;检查80h中断是否为FCD
CMP AL,80h
JZ Release_FCD_KNL
Error_KNL_Not_Found:
INC byte ptr cs:[error_count] ;错误计数+1
DOSint_PrintString msgerr_KNL_not_found
JMP Check_INT81h
NOP ;此处不加NOP指令不影响程序执行
Release_FCD_KNL:
MOV AX,8001h
INT 80h
MOV AH,49h
INT 21h
PUSH DS ;暂存DS
LDS DX,CS:[origin_80h_vector] ;加载原INT80h向量到DS:DX
MOV AX,2580h ;设定中断向量
INT 21h
POP DS ;恢复DS
DOSint_PrintString msg_FCD_KNL_Released
;检查中断向量非空
Check_INT81h:
MOV AX,3581h
INT 21h
MOV AX,ES
AND AX,BX
JZ Error_RD_Not_Found
;--------
MOV AX,8100h
INT 81h ;检查81h中断是否为FCD
CMP AL,81h
JZ Release_FCD_RD
Error_RD_Not_Found:
INC byte ptr cs:[error_count] ;错误计数+1
DOSint_PrintString msgerr_RD_not_found
JMP Check_Error_Count_and_Exit
NOP ;此处不加NOP指令不影响程序执行
Release_FCD_RD:
MOV AX,8102h
INT 81h
MOV AH,49h
INT 21h
PUSH DS
LDS DX,CS:[origin_81h_vector]
MOV AX,2581h
INT 21h
POP DS
DOSint_PrintString msg_FCD_RD_Released
JMP Check_Error_Count_and_Exit
NOP ;此处不加NOP指令不影响程序执行
;=========================================
dosint2109h PROC
MOV AH, 09h ;调用DOS中断09h输出字符串
INT 21h
RET
dosint2109h ENDP
;=========================================
Check_Error_Count_and_Exit:
CMP byte ptr cs:[error_count],00h ;检查错误计数是否为零
JNZ PrintFCDInfo ;不为零时跳过已经退出消息
DOSint_PrintString msg_FCD_exited
PrintFCDInfo:
DOSint_PrintString byte ptr msg_FCD_info
MOV AX,4C00h ;退出程序
INT 21h
msg_FCD_info db 0dh, 0ah,"The FreeCDOS Project <lijian@auts.edu.cn>", 0dh,0ah, '$'
msg_FCD_exited db 0dh,0ah,"The FreeCDOS system has exited successful!", '$'
msg_FCD_KNL_Released db 0dh,0ah,"[FCKNL.COM] has realeased!", '$'
msg_FCD_RD_Released db 0dh,0ah,"[FCRD.COM] has realeased!", '$'
msgerr_KNL_not_found db 0dh,0ah,"[FCKNL.COM] not found!", '$'
msgerr_RD_not_found db 0dh,0ah,"[FCRD.COM] not found!", '$'
origin_80h_vector dd 00000000h ;CS:[0265h]
origin_81h_vector dd 00000000h ;CS:[0269h]
error_count db 00h ;CS:[026Dh]
end start