使用 nasm 关闭计算机

发布于 2024-09-13 14:02:25 字数 144 浏览 2 评论 0原文

是否可以从 nasm 关闭或终止计算机的电源(有区别吗?)。我知道您可以使用它来重新启动:

mov al, 0xFE
out 0x64, al

是否有相当于关闭的方法? 我正在制作自己的 16 位操作系统。

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?
I am making my own 16 bit OS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

别想她 2024-09-20 14:02:25

您拥有的代码不保证能够正常工作。它依赖于两个事实:

  • 操作系统将物理 IO 内存映射到进程内存空间。
  • 机器有BIOS。

两者都可能不是真的。

以编程方式重新启动或关闭机器的唯一可靠方法是调用相应的操作系统 API。

调用操作系统 API(您需要它,因为您正在编写操作系统:-))的替代方法是使用 ACPI。并非所有机器都支持 ACPI,其中有四种不同的 ACPI 修订版。

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

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

风吹雪碎 2024-09-20 14:02:25
    mov ax, 0x1000
    mov ax, ss
    mov sp, 0xf000
    mov ax, 0x5307
    mov bx, 0x0001
    mov cx, 0x0003
    int 0x15
    mov ax, 0x1000
    mov ax, ss
    mov sp, 0xf000
    mov ax, 0x5307
    mov bx, 0x0001
    mov cx, 0x0003
    int 0x15
韶华倾负 2024-09-20 14:02:25

你可以尝试这个代码:-

shutdown_sucess:
  mov ax, 5301h             ; Connect to the APM
  xor bx, bx
  int 15h
  je near continue_connection       ; Pass if connected
  cmp ah, 2
  je near continue_connection       ; Pass if already connected
  ret               ; Bail if fail

continue_connection:
  mov ax, 530Eh             ; Check APM Version
  xor bx, bx
  mov cx, 0102h             ; v1.2 Required
  int 15h
  ret       

you can try this code:-

shutdown_sucess:
  mov ax, 5301h             ; Connect to the APM
  xor bx, bx
  int 15h
  je near continue_connection       ; Pass if connected
  cmp ah, 2
  je near continue_connection       ; Pass if already connected
  ret               ; Bail if fail

continue_connection:
  mov ax, 530Eh             ; Check APM Version
  xor bx, bx
  mov cx, 0102h             ; v1.2 Required
  int 15h
  ret       
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文