How can I shutdown the computer using only assembly code?
Converting @larz answer above to nasm assembly is done as follows:
Prerequisites: Bochs, Nasm
This example was run on debian wheezy with standard packages.
Code (filename: shutdown.asm):
org 0x7c00
jmp main
Shutdown:
mov ax, 0x1000
mov ax, ss
mov sp, 0xf000
mov ax, 0x5307
mov bx, 0x0001
mov cx, 0x0003
int 0x15
WaitForEnter:
mov ah, 0
int 0x16
cmp al, 0x0D
jne WaitForEnter
ret
main:
call WaitForEnter
call Shutdown
times 510-($-$$) db 0
dw 0xaa55
Nasm compliation:
nasm -f bin -o boot_sect.img shutdown.asm
Bochs configuration file (filename: .bochsrc) in the same directory as code (shutdown.asm)
display_library: sdl
floppya: 1_44=boot_sect.img, status=inserted
boot: a
*Note I am using the sdl library for bochs which is a seperate package from bochs itself
Running bochs (from the same directory as before):
bochs
Hit enter to shutdown
*Note I am not sure that all the lines between the Shutdown label and WaitForEnter label are neccessary