More Pascal and Turbo Vision sources:
http://www.kst.dit.ie/people/twellige/home/prog.html
In article <357597CD.5D28@Hotmail.com>,
The__Patrician@Hotmail.com wrote:
> Can anyone help me make a reboot code??? in Pascal or Assembler???
> Please help... Tanx
You can use one of the following functions:
procedure WarmReset; assembler;
asm
MOV AX,0040h
MOV ES,AX
MOV DI,0072h
MOV AX,01234h
STOSW
DB 0EAh, 00, 00,
0FFh, 0FFh
end;
procedure ColdReset; assembler;
asm
MOV AX,0040h
MOV ES,AX
MOV DI,0072h
XOR AX,AX
STOSW
DB 0EAh, 00, 00,
0FFh, 0FFh
end;
But be carefull. Both functions don't flush any existing HD cash
so you
probably destroy some importatnat data.
Check for an existing cache can be done with:
function CacheInstalled: boolean; assembler;
asm
push bp
mov ax,04A10h
mov bx,0
mov cx,0EBABh
int 2Fh
pop bp
cmp ax,0BABEh
mov ax,0
jnz @Fin
inc ax
@Fin:
end;
and flushing the cache with:
procedure FlushCache; assembler;
asm
call CacheInstalled
cmp ax,1
jnz @Fin
mov ax,04A10h
mov bx,1
int 2Fh
@Fin:
end;
Regards, Tom.
Port[$64] := $0FE;
> Q1: Does anybody know some routine to turn off your computer??
> Q2: Does anyone know a routine to put your computer on standby???
>
> If possible, the routines should not lock up, if it is not possible
to
> run these options on your computer...
>
> If you know a trick in Pascal or Assembler, please reply
>
-- Jump to address $FFFF:0000
inline ($EA/00/00/$FF/$FF);
-- call interrupt 19
asm
int $19
end
-- have the keyboard controller reset the CPU
port [$64] :=
$FE;
-- simulate keypress ctrl-alt-del
mem[$40:$17] :=
mem[$40:$17] or 12;
asm
mov
ax, $4F53
int
$15
end;
--------------------- can'----
Procedure Idle; inline ($CD/$28); { Int 28
}
Procedure boot (magic:word);
begin
memw[$40:$72] := magic;
{ set boot type }
{ simulate keypress ctrl-alt-del }
mem[$40:$17] := mem[$40:$17] or 12; { set flags of ctrl
+ alt keys }
asm
mov ax, $4F53
{ del key }
int $15
{ press it }
end;
mem[$40:$17] := mem[$40:$17] and $F0;{ release ctrl + shift
+ alt }
{ if we come here: allow cache to do staged write }
writeln;
idle; idle; idle;
write;
delay (500);
{ if we have come here: reset CPU }
port [$64] := $FE;
{ tell keyboard controller to reset
CPU }
delay (500);
{ wait until it has an effect }
{ if all didn't work, try this: }
inline ($EA/00/00/$FF/$FF);
{ jump FFFF:0000 }
{ we had no luck, so go into an endless loop }
asm
@0: jmp @0
end;
{ should NEVER NEVER NEVER come here }
end;
Procedure ColdBoot; begin boot ($0000); end;
Procedure WarmBoot; begin boot ($1234); end;
ja mata!
/ Sp00l
I received several messages about this subject asking why the jmp
wasn't
working on their comp and how come int 19 sometimes does not work
so
here it is...
First of all I should say this:
jmp F000:FFF0h
is the ONLY way to reset a 8088 from software but this is the ONLY
time
you should ever use it
so detect the cpu if your concerned about 8088 people using your
software.
( Cpu detection is another subject entirely )
int 19 is another way but usually fails for the same reason's that
the
jmp does.
if your using a mca and some eisa systems you can do it this way
this will not work on so called IBM Clones
in al,92h
; get system control port
jmp $+2
; add a slight delay
or al,1
; set bit 0 for fast reset
out 92h,al ; do
the reset
hlt
; should never get here
on AT- 286+ systems the preferred method is to use the keyboard
controller
first you should set the bios up so the kind of reset you want will
be
performed
0 is cold boot-
check memory all memory altered
1234h is warm boot skip mem check some memory may be modified
4321h is warm boot skip memory check leave ram unchanged
( useful
for preserving EMS pages in old days )
0064h cycle bios tests for manufacturing burn-in ( only some vendors
)
you want to put the value at bios address 40:72h
then we call the keyboard controller to initiate reset
Reboot proc near
xor cx,cx
; time-out counter
cmd_wait:
; loop start while waiting for buffer to empty
in al,64h
; get controller status
jmp $+2
; io delay
test al,2
; is the input buffer full ?
jz reboot
; buffer isn't full lets rock
jmp $+2
; another io delay to let buffer get flushed
loop cmd_wait
; try again
jmp cmd_error
; Error this shouldn't happen!
reboot:
mov al,0feh
; reboot command
out 64h,al
; send it, shouldn't return
cmd_error:
mov ah,1
; should NEVER get here, return error
ret
Reboot endp
Hope this clarifies it :)