Click here to Skip to main content
15,887,214 members
Articles / Programming Languages / ASM

Powering off a Computer using ACPI from DOS

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
4 Apr 2023CPOL2 min read 2.6K   1
How to power off a computer using ACPI from DOS
This blog post shows how to use ACPI from DOS to power off a computer.

By default, DOS does not come with a command to shut down or power off the computer. Back in the days, all you had to do is just to make sure that there was no disk activity going on, and press the hard power button (or in some case, yank the power cord). With SMARTDRV write buffering or Windows 3.11, you would have to make sure to return to the DOS prompt before the computer power supply can be cut off. But still, you do not need to turn off your computer by issuing a command.

On modern computers, switching off is done with the OS issuing an ACPI command telling the motherboard to turn off, which will then put the PS-ON wire (green wire) of the ATX PSU to high and allowing power to the computer to be cut off, except for some standby voltages. This is also how I use an ATX power supply as a lab power supply, by grounding the PS-ON wire and allowing the PSU to turn on by itself. This is the pinout of a typical ATX power supply connector:

g2b7h

As DOS does not support ACPI, there is no built-in way to do this if you run DOS on a modern computer. If DOS is run on a modern laptop, this means you will need to press and hold the power button to force turn off, which is not ideal.

After some research, I found a way to soft power off the computer by calling BIOS Service 53h, which is implemented by some motherboards, using the following assembly code:

ASM
mov ax,5301h
xor bx,bx
int 15h
mov ax,530eh
xor bx,bx
mov cx,0102h
int 15h
mov ax,5307h
xor bx,bx
inc bx
mov cx,0003h
int 15h
ret

The code works well for most of my computers running DOS. It does not work on my HP Compaq NC6120 – nothing will happen once the code is executed. Your mileage may vary, depending on your BIOS ACPI features.

You can download a copy of the above code here. The executable was compiled using the A86 assembler.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Writer
Singapore Singapore
Since 2008, ToughDev has been publishing technical sharing articles on a wide range of topics from software development to electronics design. Our interests include, but are not limited to, Android/iOS programming, VoIP products, embedded design using Arduino/PIC microcontrollers, reverse-engineering, retro-computing, and many others. We also perform product reviews, both on new and vintage products, and share our findings with the community. In addition, our team also develops customized software/hardware solutions highly adapted to suit your needs. Contact us for more information.

Comments and Discussions

 
QuestionACPI? Pin
Member 41880479-Apr-23 21:10
Member 41880479-Apr-23 21:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.