X86指令在实模式下关闭计算机电源? [英] X86 instructions to power off computer in real mode?

查看:148
本文介绍了X86指令在实模式下关闭计算机电源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有x86指令在实模式下任意顺序,将机器断电(不重新启动)?我有一台旧电脑使用MS-DOS还是它,我很好奇吧。

Is there any sequence of x86 instructions in real mode that will power off (not reboot) the machine? I have an old computer with MS-DOS still on it and I'm curious about it.

此问题是专讲实模式,而不是保护模式或64位长模式。

This question is specifically about real mode, not protected mode or 64-bit long mode.

推荐答案

这OSDev 文章中,您既可以使用ACPI或APM接口。 ACPI似乎过于复杂,你可以在而APM这篇文章要简单得多。当它们出现我会报告的基本步骤这里

From this article on OSDev, you can either use the ACPI or the APM interfaces. ACPI seems overcomplicated, as you can see in this article while APM is much simpler. I'll report the basic steps as they appear here:

1)的安装检查,以确定是否支持APM:

1) Installation check, to see if APM is supported:

mov ah,53h            ;this is an APM command
mov al,00h            ;installation check command
xor bx,bx             ;device id (0 = APM BIOS)
int 15h               ;call the BIOS function through interrupt 15h
jc APM_error          ;if the carry flag is set there was an error
                      ;the function was successful
                      ;AX = APM version number
                          ;AH = Major revision number (in BCD format)
                          ;AL = Minor revision number (also BCD format)
                      ;BX = ASCII characters "P" (in BH) and "M" (in BL)
                      ;CX = APM flags (see the official documentation for more details)

2)断开任何现有的接口:

2) Disconnect to any existing interface:

;disconnect from any APM interface
mov ah,53h               ;this is an APM command
mov al,04h               ;interface disconnect command
xor bx,bx                ;device id (0 = APM BIOS)
int 15h                  ;call the BIOS function through interrupt 15h
jc .disconnect_error            ;if the carry flag is set see what the fuss is about. 
jmp .no_error

.disconnect_error:       ;the error code is in ah.
cmp ah,03h               ;if the error code is anything but 03h there was an error.
jne APM_error            ;the error code 03h means that no interface was connected in the first place.

.no_error:
                         ;the function was successful
                         ;Nothing is returned.

3)连接到真正的模式界面(01H):

3) Connect to the real mode interface (01h):

;connect to an APM interface
mov ah,53h               ;this is an APM command
mov al,[interface_number];see above description
xor bx,bx                ;device id (0 = APM BIOS)
int 15h                  ;call the BIOS function through interrupt 15h
jc APM_error             ;if the carry flag is set there was an error
                         ;the function was successful
                         ;The return values are different for each interface.
                         ;The Real Mode Interface returns nothing.
                         ;See the official documentation for the 
                         ;return values for the protected mode interfaces.

4)所有设备启用电源管理:

4) Enable power management for all devices:

;Enable power management for all devices
mov ah,53h              ;this is an APM command
mov al,08h              ;Change the state of power management...
mov bx,0001h            ;...on all devices to...
mov cx,0001h            ;...power management on.
int 15h                 ;call the BIOS function through interrupt 15h
jc APM_error            ;if the carry flag is set there was an error

5)最后,电源状态设置为关闭(03H):

5) Finally, set the power state to off (03h):

;Set the power state for all devices
mov ah,53h              ;this is an APM command
mov al,07h              ;Set the power state...
mov bx,0001h            ;...on all devices to...
mov cx,[power_state]    ;see above
int 15h                 ;call the BIOS function through interrupt 15h
jc APM_error            ;if the carry flag is set there was an error

这篇关于X86指令在实模式下关闭计算机电源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆