J'ai des soucis de traduction d'un code Asm dont la source est http://code.google.com/p/ostin/source/d ... utdown.asm
et dont l'objet est de reproduire un shutdown sans utiliser d'api windows.
Code : Tout sélectionner
Macro ShutDown
;;======================================================================================================================
;;///// shutdown.asm /////////////////////////////////////////////////////////////////////////////////////// GPLv2 /////
;;======================================================================================================================
;; (c) 2004-2008 KolibriOS team <http://kolibrios.org/>
;; (c) 2003 MenuetOS <http://menuetos.net/>
;;======================================================================================================================
;; This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
;; License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later
;; version.
;;
;; This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License along with this program. If not, see
;; <http://www.gnu.org/licenses/>.
;;======================================================================================================================
EnableASM
Define old_ints_h=0
!align 4
;-----------------------------------------------------------------------------------------------------------------------
pr_mode_exit: ;/////////////////////////////////////////////////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------------------------------------------------
; setup stack
!mov ax, [3000h]
!mov ss, ax
!mov esp, [ec00h]
; setup ds
!push cs
!pop ds
!lidt [old_ints_h]
; remap IRQs
!mov al, [11h]
!out 20h, al
!call l_rdelay
!out a0h, al
!call l_rdelay
!mov al, 8h
!out 21h, al
!call l_rdelay
!mov al, [70h]
!out a1h, al
!call l_rdelay
!mov al, [04h]
!out 21h, al
!call l_rdelay
!mov al, [2h]
!out a1h, al
!call l_rdelay
!mov al, [1h]
!out 21h, al
!call l_rdelay
!out a1h, al
!call l_rdelay
!mov al, [b8h]
!out 21h, al
!call l_rdelay
!mov al, [bdh]
!out a1h, al
!sti
temp_3456:
!xor ax, ax
!mov es, ax
!mov al, [es:BOOT_VRR]
!cmp al, 1
!jl .nbw
!cmp al, 4
!jle .nbw32
nbw:
!in al, 60h
!cmp al, 6
!jae l_nbw
!mov bl, al
nbw2:
!in al, 60h
!cmp al, bl
!je l_nbw2
!cmp al, 240 ; ax, 240
!jne l_nbw31
!mov al, bl
!dec ax
!jmp l_nbw32
nbw31:
!add bl, 128
!cmp al, bl
!jne l_nbw
!sub al, 129
nbw32:
!dec ax
!dec ax ; 2 = power off
!jnz l_no_apm_off
!call l_APM_PowerOff
!jmp $
no_apm_off:
!dec ax ; 3 = reboot
!jnz l_restart_kernel ; 4 = restart kernel
!push [40h]
!pop ds
!mov word[72h], 1234h
!jmp f000h:fff0h
restart_kernel:
!mov ax, [0003h] ; set text mode for screen
!int 10h
!jmp 4000h:0
;-----------------------------------------------------------------------------------------------------------------------
rdelay: ;///////////////////////////////////////////////////////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------------------------------------------------
!ret
;-----------------------------------------------------------------------------------------------------------------------
APM_PowerOff: ;/////////////////////////////////////////////////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------------------------------------------------
!mov ax, [5304h]
!xor bx, bx
!int 15h
;!!!!!!!!!!!!!!!!!!!!!!!!
!mov ax, [5300h]
!xor bx, bx
!int 15h
!push ax
!mov ax, [5301h]
!xor bx, bx
!int 15h
!mov ax, [5308h]
!mov bx, 1
!mov cx, bx
!int 15h
!mov ax, [530eh]
!xor bx, bx
!pop cx
!int 15h
!mov ax, [530dh]
!mov bx, 1
!mov cx, bx
!int 15h
!mov ax, [530fh]
!mov bx, 1
!mov cx, bx
!int 15h
!mov ax, [5307h]
!mov bx, 1
!mov cx, 3
!int 15h
;!!!!!!!!!!!!!!!!!!!!!!!!
!ret
;-----------------------------------------------------------------------------------------------------------------------
restart_kernel_4000: ;//////////////////////////////////////////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------------------------------------------------
!cli
!push ds
!pop es
!mov cx, [8000h]
!push cx
!push [7000h]
!pop ds
!xor si, si
!xor di, di
!rep movsw
!pop cx
!mov ds, cx
!push [2000h]
!pop es
!rep movsw
!push [9000h]
!pop ds
!push [3000h]
!pop es
!mov cx, [e000h / 2]
!rep movsw
!wbinvd ; write and invalidate cache
!mov al, 00110100b
!out 43h, al
!jcxz $ + 2
!mov al, [ffh]
!out 40h, al
!jcxz $ + 2
!out 40h, al
!jcxz $ + 2
!sti
; We must read data from keyboard port,
; because there may be situation when previous keyboard interrupt is lost
; (due to return to real mode and IRQ reprogramming)
; and next interrupt will not be generated (as keyboard waits for handling)
!in al, 60h
; bootloader interface
!push [1000h]
!pop ds
!mov si, l_kernel_restart_bootblock
!mov ax, 'KL'
!jmp 1000h:0
DisableASM
EndMacro