0

I just started programming in assembly, I started with a simple program with a print, input and new line function. Then I wondered how to shutdown the machine and I found this function online:

shutdown:
    mov ax, 0x1000
    mov ax, ss
    mov sp, 0xf000
    mov ax, 0x5307
    mov bx, 0x0001
    mov cx, 0x0003
    int 0x15

This code works but I need to know why.

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
  • 2
    Check a manual: [INT 15/AX=5307H SET POWER STATE](http://www.techhelpmanual.com/38-int_15h_5307h__set_power_state.html). It's an APM call to shut down the system. – fuz Apr 30 '23 at 19:54
  • 1
    `mov ax, 0x1000` `mov ax, ss` `mov sp, 0xf000` Are you sure you copied the code correctly? Loading AX twice is silly. Shouldn't it be: `mov ax, 0x1000` `mov ss, ax` ? – Sep Roland Apr 30 '23 at 21:27
  • Does this answer your question? [X86 instructions to power off computer in real mode?](https://stackoverflow.com/questions/21463908/x86-instructions-to-power-off-computer-in-real-mode) – x444556 May 01 '23 at 16:21
  • @SepRoland I literally do copy and paste – Federico Occhiochiuso May 02 '23 at 12:21
  • @x444556 The codes are different, on this page it's much more complicated. However, of this code I didn't understand only the first 4 lines:```mov ax, 0x1000``` ```mov ax, ss``` ```mov sp, 0xf000``` ```mov ax, 0x5307``` – Federico Occhiochiuso May 02 '23 at 12:26

0 Answers0