assemblyoperating-systemx86shutdownsystem-shutdown

How to shutdown the machine? I'm building a tiny OS of my own


Can the hlt instruction in assembly shutdown a computer it as it halts the processor? if it can be done using what i have told, is it the right way?

Can hlt shutdown the machine?

start:
    xor ax, ax; ;clear ax
    mov bx, ax; ;clear bx
    cli ;stop all interrupts
    hlt ;halt the cpu

If this is not the way to be done of if this will not shutdown the system please tell me the right way to do it.


Solution

  • The hlt instruction stops the x86 until an interrupt occurs. Unless all interrupts are disabled, that will stop the processor for only a millisecond or so.

    To power down a modern computer, use the ACPI (Advanced Configuration and Power Interface).