x86 Assembly

Moderators: None (Apply to moderate this forum)
Number of threads: 4563
Number of posts: 16029

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to shutdown computer.. Posted by nec2152 on 14 Feb 2006 at 5:20 PM
I am looking for how to shutdown computer directly, like windows 98/xp does on new ATX systems, without displaying 'You may safely turn off the computer'.
can anybody help...
Report
Re: how to shutdown computer.. Posted by jeffleyda on 15 Feb 2006 at 8:09 AM
: I am looking for how to shutdown computer directly, like windows 98/xp does on new ATX systems, without displaying 'You may safely turn off the computer'.
: can anybody help...
:

http://www.delorie.com/djgpp/doc/rbinter/ix/15/53.html

INT 15, function 53xx has some function to do such cpu state handling.

You can also do it directly by accessing the ACPI controller in the southbridge.

Through ACPI, you can send simple I/O writes to the ACPI block to put the machine into any state you want, including power off.

If you want to go the ACPI way, there's dos and windows source code available here:

http://www.oldskool.org/pc/throttle

-jeff!
Report
Re: how to shutdown computer.. Posted by tsagld on 16 Feb 2006 at 12:59 AM
: : I am looking for how to shutdown computer directly, like windows 98/xp does on new ATX systems, without displaying 'You may safely turn off the computer'.
: : can anybody help...
: :
:
: http://www.delorie.com/djgpp/doc/rbinter/ix/15/53.html
:
: INT 15, function 53xx has some function to do such cpu state handling.
:
: You can also do it directly by accessing the ACPI controller in the southbridge.
:
: Through ACPI, you can send simple I/O writes to the ACPI block to put the machine into any state you want, including power off.
:
: If you want to go the ACPI way, there's dos and windows source code available here:
:
: http://www.oldskool.org/pc/throttle
:
: -jeff!
:
From Windows, you can call
ExitWindowsEx(EWX_POWEROFF, 0);


Greets,
Eric Goldstein
www.gvh-maatwerk.nl

Report
Re: how to shutdown computer.. Posted by Luke7 on 2 Mar 2006 at 2:32 PM
: I am looking for how to shutdown computer directly, like windows 98/xp does on new ATX systems, without displaying 'You may safely turn off the computer'.
: can anybody help...
:

I have the code and executable to do just what you want.

It'll shutdown XP and Win 2K with just one double click.

Give me your email and I can send it to you.


Report
Re: how to shutdown computer.. Posted by Chainsaw666 on 7 Mar 2006 at 8:43 PM
Just push the power button!

Report
Re: how to shutdown computer.. Posted by Luke7 on 15 Mar 2006 at 12:23 PM
: Just push the power button!
:
:

You're so funny. Don't quit your day job.

Report
Re: how to shutdown computer.. Posted by holus on 26 Jan 2011 at 2:59 PM
Did you get some useful information with this old post.
I’m trying to make my own OS and always hated the “you can turn your computer off” message. SO: Not in my OS!!!!!!

I’m looking for a simple ASM-code to shutdown.
Int 15 doesn’t work. But maybe it just doesn’t work in DOS (win 95 ver 4.00.1111)
Because Bill doesn’t want us to use the “power down cycle”.

Making your own OS and FAT isn't that easy for just try if that's the problem. Beybe you just know the answer.
Report
Re: how to shutdown computer.. Posted by Bret on 26 Jan 2011 at 6:07 PM
If the computer is fairly old and only has an APM-compatible BIOS, it's relatively simple to shut down using INT 15h. If the computer is only somewhat old, it may have both APM and ACPI, in which case INT 15h should also work. If the computer is new enough, though, it may only have ACPI. ACPI is nasty.

The source code for FDAPM (a FreeDOS utility) has what you're looking for.
Report
Re: how to shutdown computer.. Posted by mercury0x000d on 2 May 2011 at 2:02 PM
I faced this same problem in making my own OS. Using information I found on Toshihiro Horie's website, I made these routines to do the job:

DEFINT A-Z
SUB APMGetVer(vMajor, vMinor, APMState)
'returns Advanced Power Management BIOS version
rAX = 0
rCX = 0
!mov ax, &h5300
!mov bx, &h0
!int &h15
!mov rAX, ax
!mov rCX, cx
vMajor = rAX \ 256
vMinor = rAX AND 255
IF rCX AND 8 THEN
APMState = 0
ELSE
APMState = 1
END IF
END SUB

DEFINT A-Z
SUB APMActivate (activateFlag)
'enables APM for everything controlled by the APM BIOS
'to enable APM, activateFlag = 1
'to disable APM, activateFlag = 0
af = 0
rAX = 0
!mov ax, &h530D
!mov bx, &h01
!mov cx, af
!int &h15
!mov rAX, ax
errorFlag = rAX \ 256
select case errorFlag
CASE 1:sysErr = &h21C:error 1
CASE 3:sysErr = &h21E:error 1
CASE 9:sysErr = &h221:error 1
CASE &h0A:sysErr = &h222:error 1
end select
END SUB

DEFINT A-Z
SUB APMShutdown
rAX = 0
!mov ax, &h5301
!mov bx, &h0
!int &h15
!mov rAX, ax
SELECT CASE rAX \ 256
CASE 2:sysErr = &h21D:error 1
CASE 5:sysErr = &h21F:error 1
CASE 7:sysErr = &h220:error 1
CASE 9:sysErr = &h221:error 1
CASE &h86:sysErr = &h223:error 1
END SELECT
!mov ax, &h530E
!mov bx, &h00
!mov cx, &h102
!int &h15
'SET POWER STATE OF ALL DEVICES TO OFF...
!mov ax, &h5307
!mov bx, &h01
!mov cx, &h03
!int &h15
END SUB

You would need to execute these routines in the order they're listed. First, determine if the APM BIOS is available, then activate it, then shut everything down. This has worked on every machine I've tried it on so far. In case you're wondering about the lines beginning with "!", this code is in a language called PowerBASIC, which allows the mixing of assembly and traditional BASIC code in one file. Also keep in mind, there's no way to do this under Windows XP and later since Windows traps and stops all direct runs at the hardware. Instead, it just terminates your program.

Hope this helps :)
Mercury0x000D



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.