flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Power Off Question |
Author |
|
Octavio 25 Oct 2006, 12:33
http://groups.google.es/group/comp.lang.asm.x86/browse_thread/thread/a84018d53cb7422e/1535b9e55bb0266b?lnk=st&q=octasm+power+off&rnum=1&hl=es#1535b9e55bb0266b
I posted assembly code to do this, it uses bios interrupts ,see RBIL for explanations http://www.ctyme.com/rbrown.htm |
|||
25 Oct 2006, 12:33 |
|
grimpirate 26 Oct 2006, 06:22
Thx alot Octavio, that really helps and I actually put the interrupt in there and got it to work So here it is for the sake of helping someone else out who might need it.
Code: boot_start equ 0x7c00 jmp boot_code nop times 59 db 0xff boot_code: mov si, boot_start + message mov ah, 0x0e mov bx, 0x07 @@: lodsb or al, al jz @f int 0x10 jmp @b @@: mov ah, 0x00 int 0x16 mov ax, 0x5307 mov bx, 0x0001 mov cx, 0x0003 int 0x15 message db 'Hello World!', 13, 10 db 'Press any key to shut down computer...', 0 times 510 - $ db 0 db 0x55, 0xaa NOTE: My code isn't as well done as Octavio's his actually checks that the Interrupt exists and is functional. I don't quite understand all of it, but I figure that's what it's doing. |
|||
26 Oct 2006, 06:22 |
|
smiddy 26 Oct 2006, 12:40
Here's what I'm using from a PM OS:
Code: PowerManagmentVersion dw 0 NoPowerManagment db 'No power management functionality',10,13,0 ErrorMessage db 'Power management error',10,13,0 WrongVersion db 'Need APM version 1.1 or better',10,13,0 PowerDown: mov ax,5300h ; See if APM available mov bx,0 ; device = BIOS int 15h mov si,NoPowerManagment jc .Error cmp ax,101h ; See if version 1.1 or greater mov dx,WrongVersion jc .Error mov [PowerManagementVersion],ax mov ax,5301h ; Do a real mode connection mov bx,0 ; device = BIOS int 15h jnc .NoConectionError cmp ah,2 ; Pass if already connected mov si,ErrorMessage ; else error jnz .Error .NoConnectionError: mov ax,530eh ; Enable latest version of APM mov bx,0 ; device = BIOS mov cx,[PowerManagmentVersion] ; version int 15h mov si,ErrorMessage jc .Error mov ax,530dh ; Now engage and enable CPU management mov bx,1 ; device = all mov cx,1 ; enable int 15h mov si,ErrorMessage jc .Error mov ax,530fh mov bx,1 ; device = ALL mov cx,1 ; enable int 15h mov si,ErrorMessage jc .Error mov ax,5307h ; Do the power down mov bx,1 ; device = ALL mov cx,3 ; mode = OFF int 15h ; shutdown CPU mov si,ErrorMessage .Error: call PrintString ret |
|||
26 Oct 2006, 12:40 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.