views:

49

answers:

1

Is it possible to shut down or kill the power (is there a difference?) to a computer from nasm. I know you can use this to reboot:

mov al, 0xFE
out 0x64, al

Is there an equivalent for shutting down?

+1  A: 

The code you have is not guaranteed to work. It relies on two facts:

  • the OS maps the physical IO memory into the process memory space.
  • the machine has BIOS.

Neither of the two might be true.

The only reliable way to reboot or shutdown the machine programatically is to call the corresponding OS API.

An alternative to calling the OS API (which you need, since you are writing the OS :-)) is using ACPI. Not all machines support ACPI an of these that do, there's at four different ACPI revisions.

http://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface?wasRedirected=true
http://www.acpi.info

Franci Penov
I am making my own 16 bit OS, so there is no OS API.
None
you should've started with this bit of information. :-) There is no simple standardized way of shutting down the machine that works across all motherboards. You can look into ACPI for power management support; however the ACPI support varies widely, so you need to know what hardware you're running on
Franci Penov