|
Wengier
系统支持
             “新DOS时代”站长
积分 27736
发帖 10521
注册 2002-10-9
状态 离线
|
『楼 主』:
DOS下软关机程序的源代码
使用 LLM 解释/回答一下
DOS下的软关机程序有不少,我知道的就有SHUTDOWN、POWEROFF、OFF、PLOP等等。这儿有PLOP的源代码:
http://plop.at/files/SHUTDOWN.ASM
There are quite a few soft shutdown programs under DOS. The ones I know include SHUTDOWN, POWEROFF, OFF, PLOP, etc. Here is the source code of PLOP:
http://plop.at/files/SHUTDOWN.ASM
|

Wengier - 新DOS时代
欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/
E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)
 |
|
2002-11-28 00:00 |
|
|
herons
初级用户
 
积分 126
发帖 6
注册 2002-11-20
状态 离线
|
『第 2 楼』:
[已使用 LLM 解释]
用这么麻烦吗?
.model tiny
.286
.code
org 100h
mov ax, 5301h ;APM v1.1 or v1.2 BIOS switches to APM v1.0
mov bx,0 ;compatibility mode
int 15h ;
mov ax, 5307h ;TURN OFF SYSTEM
mov bx, 1
mov cx, 3
int 15h
;mov ax,4c00h
;int 21h
end
Is it so troublesome?
.model tiny
.286
.code
org 100h
mov ax, 5301h ;APM v1.1 or v1.2 BIOS switches to APM v1.0
mov bx,0 ;compatibility mode
int 15h ;
mov ax, 5307h ;TURN OFF SYSTEM
mov bx, 1
mov cx, 3
int 15h
;mov ax,4c00h
;int 21h
end
LLM 解释
代码解释与相关说明
代码部分分析
.model tiny :这是定义内存模式为tiny模式,tiny模式下程序代码和数据都放在64KB以内的一个段中。
.286 :指定使用80286及以上的处理器指令集。
org 100h :指定程序的起始偏移地址为100h,这是DOS下COM文件的默认起始偏移地址。
mov ax, 5301h ;APM v1.1 or v1.2 BIOS switches to APM v1.0
mov bx,0 ;compatibility mode
int 15h ;
这里是通过INT 15h中断调用,功能号5301h来将高级电源管理(APM)版本切换到兼容模式(bx = 0)。INT 15h是BIOS中断,不同的功能号有不同的作用,这里是用于APM相关的操作。
mov ax, 5307h ;TURN OFF SYSTEM
mov bx, 1
mov cx, 3
int 15h
功能号5307h用于执行关机操作,bx = 1表示是关机操作,cx = 3表示具体的关机相关参数设置等。通过INT 15h中断来触发关机动作。
;mov ax,4c00h
;int 21h
这部分原本是用于程序正常返回DOS的代码(通过INT 21h中断,功能号4C00h返回),但在这个关机程序中,因为要执行关机操作,所以被注释掉了,程序执行到关机相关的INT 15h调用后就会进行关机,不会再返回DOS了。
DOS下软关机的其他可行方案
.model tiny
.286
.code
org 100h
start:
mov ax,0
int 19h ; BIOS的重启/关机相关中断,不同的实现可能有不同表现,有些系统中可以用于关机
end start
不过这种方式的兼容性可能不如使用APM相关中断好,不同的硬件和BIOS对INT 19h的处理可能不一样。
-
调用DOS功能调用间接关机(较不常用)
虽然通常DOS功能调用主要用于文件操作等,但也可以通过一些技巧间接实现,不过这种方式相对复杂且兼容性较差,例如:
.model tiny
.286
.code
org 100h
start:
mov ax,0
mov ah,0
int 21h ; 其实这种方式很难直接用于关机,只是简单示例一种思路,实际不可行
end start
总的来说,使用APM相关的INT 15h中断功能号5307h的方式是比较常用的软关机实现方式,但需要注意不同硬件和BIOS的兼容性问题。上述代码在符合80286及以上处理器、DOS环境下可以尝试运行来实现软关机功能,但在一些较旧或兼容性不好的环境中可能无法正常工作。
用三个反引号包裹代码,语言标注为asm:
.model tiny
.286
.code
org 100h
mov ax, 5301h ;APM v1.1 or v1.2 BIOS switches to APM v1.0
mov bx,0 ;compatibility mode
int 15h ;
mov ax, 5307h ;TURN OFF SYSTEM
mov bx, 1
mov cx, 3
int 15h
;mov ax,4c00h
;int 21h
end
|
|
2002-11-28 00:00 |
|
|
LiveOnLove
中级用户
  
积分 493
发帖 161
注册 2002-10-29 来自 ZHCN
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
在那时只知道WIN可以自动关机啊。后来分析了一个网卡的TEST程序,其中有一个叫APM.COM的程序,就是和二楼的差不多,还可以软关机显示器,可以看到显示器的POWER LED在闪烁。
Last edited by LiveOnLove on 2016-7-14 at 13:02 ]
At that time, I only knew that WIN could automatically shut down. Later, I analyzed a TEST program of a network card, and there was a program called APM.COM, which was similar to the one on the second floor. It could also soft - shut down the monitor, and I could see that the POWER LED of the monitor was flashing.
Last edited by LiveOnLove on 2016-7-14 at 13:02 ]
|
|
2002-11-29 00:00 |
|
|
copy114
初级用户
 
积分 229
发帖 37
注册 2002-11-9
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
哦!有了这些源代码,用什么软件把它编译成EXE啊?
Oh! With these source codes, what software can be used to compile them into EXE?
|
|
2002-11-30 00:00 |
|
|
Wengier
系统支持
             “新DOS时代”站长
积分 27736
发帖 10521
注册 2002-10-9
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
最简单的是用DEBUG编成EXE文件,或者正规的话用MASM等编译。
The simplest way is to use DEBUG to compile into an EXE file, or formally use MASM and other compilers.
|

Wengier - 新DOS时代
欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/
E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)
 |
|
2002-11-30 00:00 |
|
|
LiveOnLove
中级用户
  
积分 493
发帖 161
注册 2002-10-29 来自 ZHCN
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
是用DEBUG编成COM文件吧?
例如:
C:\windows\>debug
-A(''-''是DEBUG的提示符号,A是DEBUG的汇编命令,输入A后回车)
XXXX:0100 mov ax, 5301(XXXX:0100是内存的代码段(随机的)和DEBUG自动给出的偏移,以下略)
mov bx,0
int 15
mov ax, 5307
mov bx, 1
mov cx, 3
int 15
mov ax,4c00
int 21
-rcx
25(CX寄存器表示文件长度,这里输入的比实际大些)
-n POWEROFF.com(给文件取名)
-w(写入文件)
-Q(退出DEBUG)
Ok,运行POWEROFF.com就可以看到效果了
Is it compiled into a COM file using DEBUG?
For example:
C:\windows\>debug
-A('-' is the prompt symbol of DEBUG, A is the assembly command of DEBUG, enter after inputting A)
XXXX:0100 mov ax, 5301(XXXX:0100 is the code segment of memory (random) and the offset automatically given by DEBUG, and the following is omitted)
mov bx,0
int 15
mov ax, 5307
mov bx, 1
mov cx, 3
int 15
mov ax,4c00
int 21
-rcx
25(CX register represents the file length, here input is a bit larger than the actual)
-n POWEROFF.com(name the file)
-w(write the file)
-Q(quit DEBUG)
Ok, run POWEROFF.com to see the effect
|
|
2002-12-1 00:00 |
|
|
worrk
初级用户
 
积分 124
发帖 7
注册 2002-12-9
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
呵,谢谢了,我看的很清楚!
Hehe, thanks, I can see very clearly!
|
|
2002-12-10 00:00 |
|
|
柳飘逸
初级用户
 
积分 119
发帖 11
注册 2002-12-14
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
能不能说一下用MASM的操作
Can you tell me about the operations with MASM?
|

ぁ拒签ぁ!!!!!!!!!!!!! |
|
2002-12-14 00:00 |
|
|
superdos
中级用户
  
积分 272
发帖 43
注册 2003-4-4
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
mov bx,0
int 15
mov ax, 5307
mov bx, 1
mov cx, 3
int 15
mov ax,4c00
int 21
这些是什么意思?
What do these mean?
|
|
2003-4-4 00:00 |
|
|
Wengier
系统支持
             “新DOS时代”站长
积分 27736
发帖 10521
注册 2002-10-9
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
前面是调用INT15中断以执行关机操作,后面是退出。
The front is calling the INT15 interrupt to perform the shutdown operation, and the back is exiting.
|

Wengier - 新DOS时代
欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/
E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)
 |
|
2003-4-4 00:00 |
|
|
lydong
元老会员
        
积分 1468
发帖 407
注册 2002-10-21 来自 广州
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
软关机和重新启动的程序已经有这么多了,可是还没有可以直接重新启动DOS的程序,下面这个程序:
C>DEBUG↓
-A↓
XXXX:0100 XOR AX,AX↓
XXXX:0102 INT 19↓
XXXX:0104 ↓
-N,CQ.COM↓
-RCX↓
:4↓
-W↓
-Q↓
和 Wengier 写的:
MOV AX,0
INT 19
都不能顺利重启DOS.都是刚出现启动画面时就死机了,请问谁有办法呢?
There are already so many programs for soft shutdown and restart, but there is still no program that can directly restart DOS. The following program:
C>DEBUG↓
-A↓
XXXX:0100 XOR AX,AX↓
XXXX:0102 INT 19↓
XXXX:0104 ↓
-N,CQ.COM↓
-RCX↓
:4↓
-W↓
-Q↓
And the one written by Wengier:
MOV AX,0
INT 19
Both cannot restart DOS smoothly. They all crash when the boot screen just appears. Does anyone have a way?
|

欢迎大家观临我的个人主页:
http://dosdiy.bluepc.com.cn/
http://dosdiy.ys168.com/
EMAIL: lydong@china.com.cn lydong@yeah.net
----------------------------------------------
|
|
2003-4-7 00:00 |
|
|
lydong
元老会员
        
积分 1468
发帖 407
注册 2002-10-21 来自 广州
状态 离线
|
|
2003-4-8 00:00 |
|
|
iwons
初级用户
 
积分 114
发帖 5
注册 2003-4-2
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
97就想在DOS下编写一个程序实现软关机功能......那时请教了很多老师都不知道怎样编写...
现在,呵呵..........终于知道了,却是在5年之后
In 1997, I just wanted to write a program under DOS to implement the soft shutdown function... At that time, I asked many teachers but none knew how to write it... Now, heh heh.......... Finally knew, but it was 5 years later
|
|
2003-4-10 00:00 |
|
|
Wengier
系统支持
             “新DOS时代”站长
积分 27736
发帖 10521
注册 2002-10-9
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
那个RE-BOOT软件我也有,不过系统启动(即重启OS)那个功能在我的两台电脑上都不能用,在第三台旧电脑上虽能用,但却发现并不是很稳定.
I also have the RE-BOOT software, but the function of system startup (that is, rebooting the OS) doesn't work on both of my two computers. On the third old computer, although it can be used, it is found to be not very stable.
|

Wengier - 新DOS时代
欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/
E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)
 |
|
2003-4-10 00:00 |
|
|
lydong
元老会员
        
积分 1468
发帖 407
注册 2002-10-21 来自 广州
状态 离线
|
|
2003-4-10 00:00 |
|