Board index » delphi » Runtime error 200 with 16bit protected mode

Runtime error 200 with 16bit protected mode

I have yet to find a patch program that can patch a pascal program
already
compiled in 16bit protected mode with BP7.  Yes I seen the many patch
programs
and tried they are for 8bit programs or for patching the library files
witch requires
the compiler. All I have is the executable. Is it possible or not
possible to patch
a 16bit protected mode pascal program that has already been compiled ?

 

Re:Runtime error 200 with 16bit protected mode


Quote
In article <3565C38E.1240E...@mediaone.net>, kairo  <ka...@mediaone.net> wrote:
>I have yet to find a patch program that can patch a pascal program
>already
>compiled in 16bit protected mode with BP7.  Yes I seen the many patch
>programs
>and tried they are for 8bit programs or for patching the library files
>witch requires
>the compiler.

There are no such a thing as 8 bit programs in context of TP/BP 7.0.
Try following with the /nd switch. That is "DFix xxxx.exe /nd". It will
cause all delays to become non-existent. If you omit the "/nd" then it
will not work in PM. (Then delays will work but the program will fail
again when the computers get 'factor' times faster. With "/nd" the
program is fixed for good). Note I take no responsibility. Always keep a
backup copy of the program (make it before patching and keep it for
good)

Program Dfix;
uses dos;

Var buff:array[1..32768] of byte;

Var factor:1..1191;

const Division:array[1..10] of integer=
               ($f7,$d0,$f7,$d2,$B9,-1,-1,$f7,$f1,$a3);

      delay:array[1..19] of integer=($8e,6,-1,-1,$33,$ff,$26,$8a,$1d,
                                     $a1,-1,-1,$33,$d2,$e8,5,0,$e2,$f6);

      newdelay:array[1..19] of byte=($33,$ff,$8e,$c7,$26,$8a,$1d,
                                     $b8,0,0,$f7,$26,0,0,$e8,5,0,$e2,$f4);

      fixeddelay:array[1..19] of integer=($33,$ff,$8e,$c7,$26,$8a,$1d,$b8,
                                          -1,-1,$f7,$26,-1,-1,$e8,5,0,$e2,$f4);

      delayloop:array[1..14] of integer=($2d,1,0,$83,$da,0,$72,5,$26,
                                         $3a,$1d,$74,$f3,$c3);

Procedure Backup(st:string);
var fp,fp2:file;
    s:string[4];
    d:dirstr;
    n:namestr;
    e:extstr;
    i:integer;
    bytesread:word;
    t:longint;
begin
  fsplit(st,d,n,e);
  {$i-}
  for i:=1 to 999 do begin
    str(1000+i:3,s);
    delete(s,1,1);
    assign(fp,d+n+'.'+s);
    reset(fp,1);
    if ioresult>0 then break;
    close(fp);
    if ioresult>0 then;
  End;
  {$i+}
  assign(fp,d+n+'.'+s);
  rewrite(fp,1);
  assign(fp2,st);
  reset(fp2,1);
  repeat
    blockread(fp2,buff,sizeof(buff),bytesread);
    blockwrite(fp,buff,bytesread);
  until bytesread=0;
  getftime(fp2,t);
  setftime(fp,t);
  close(fp);
  close(fp2);
End;

var ind:longint;
    i,j:integer;
    bytesread:word;
    fp:file;

Function Find(data:array of integer):longint;
var ind:longint;
label out;
Begin
  ind:=0;
  repeat
    seek(fp,ind);
    blockread(fp,buff,sizeof(buff),bytesread);
    i:=1;
    while i<bytesread-20 do begin
      if buff[i]=data[0] then begin
         for j:=1 to high(data) do if (data[j]>=0) and (buff[i+j]<>data[j])
             then goto out;
         Find:=ind+i-1;
         exit;
      End;
   out:
     inc(i);
    End;
    inc(ind,bytesread-50);
 until bytesread<=50;
 find:=-1;
End;

Procedure Error;
begin
  Writeln('Dfix: Could not find CRT unit!"');
  close(fp);
  halt;
End;

Procedure FixNoDelay;
var x:byte;
    ind:longint;
Begin
  ind:=find(Delayloop);
  if ind<0 then error;
  x:=$c3;
  Seek(fp,ind);
  blockwrite(fp,x,1);
End;

Procedure FixDelay;
var ind,ind2,countindex:longint;

    xx:word;
Begin
  ind:=Find(Division);
  if ind<0 then error;
  ind2:=Find(Delay);
  Countindex:=ind2+10;
  if ind2<0 then begin
      ind2:=Find(FixedDelay);
      if ind2<0 then error;
      countindex:=ind2+12;
  End;

  xx:=55*factor;

  seek(fp,countindex);
  blockread(fp,newdelay[13],2);

  seek(fp,ind+5);
  blockwrite(fp,xx,2);
  seek(fp,ind2);
  newdelay[9]:=lo(factor);
  newdelay[10]:=hi(factor);

  Blockwrite(fp,newdelay,sizeof(newdelay));
End;

label out;

var x:word;
    err:integer;

begin
  factor:=10;
  filemode:=2;
  if paramcount<1 then runerror(255);
  assign(fp,paramstr(1));
  backup(paramstr(1));
  reset(fp,1);
  val(paramstr(2),x,err);
  if err=0 then factor:=x;

  if (paramstr(2)='/nd') then FixNoDelay
     else FixDelay;
  close(fp);
  Writeln('Program fixed');

End.

Osmo

Re:Runtime error 200 with 16bit protected mode


What you mean no such thing as 8bit programs ?
what do you call a non 16bit PM program then, cant be 16 bit can it ?
Turbo pascal has been around since I had the 8088 and that was an 8bit cpu
16 bit was barely around back then if at all.
thanks for the program i'll try it out.

Re:Runtime error 200 with 16bit protected mode


In article <35672948.1627A...@mediaone.net>, kairo <ka...@mediaone.net>
writes

Quote
>What you mean no such thing as 8bit programs ?

Not on the PC. Even the first IBM PC chips (8086/8) ran in 16bit mode.

Quote
>what do you call a non 16bit PM program then

16bit real mode program.

Quote
>Turbo pascal has been around since I had the 8088 and that was an 8bit cpu

It was a 16 bit CPU identical to the 8086 except that it happened to
fetch instructions in 8bit chunks.

--
Pedt Scragg                    <newsmas...@pedt.demon.co.uk>

Never curse the Crocodile's mother before crossing the river

Re:Runtime error 200 with 16bit protected mode


Quote
In article <35672948.1627A...@mediaone.net>, kairo  <ka...@mediaone.net> wrote:
>What you mean no such thing as 8bit programs ?
>what do you call a non 16bit PM program then, cant be 16 bit can it ?

You mean a program compiled with Turbo Pascal? It is a 16-bit real mode
program.

Quote
>Turbo pascal has been around since I had the 8088 and that was an 8bit cpu
>16 bit was barely around back then if at all.

8088 was internally 16-bits though it was externally 8 bits for easy
interface to existing 8-bit hardware. The 8-bit processors that
proceeded it were 8080 and 8085. 8086/8088 is at assembler level
compatible with 8080.

Hoe can one know that 8088 was 16-bits? Well looking instructions. For
every basic 8-but operation there is comparable 16-bit operation
that executes in the same time (in the core, fetching the data is a
different thing). If one compares this to 8-bit processor like Z80
(another processor comparable to 8080, something like a cousin to 8088).
While it had some 16-bit instructions, like ADD or LD (MOV) those were
limited and slower than the 8-bit ones. (8-bit add was 4 time states
(cycles) and 16-bit one 11). So mere existence of 16-bit registers do
not show that the CPU is 16-bits. It is how those are handled i.e. the
internal data paths that count.

Osmo

Re:Runtime error 200 with 16bit protected mode


Anyways your patch program didnt work. Any ideas why ?
The only thing different that happened was the runtime error occured in a different

address than before it was patched.

Thats interesting on the 16bit thing, but I never looked at an EXE to see if it was
16 or 8
bit after compilation.  Pascal was a good language years ago, but I hate my self
for
using it for so long, no one uses it in business anymore mostly school stuff and
C++ is
pretty much the standard now. oh well.

Re:Runtime error 200 with 16bit protected mode


Runtime error 200 at 0002:3ECF. after patching
Runtime error 200 at 000A:310B. before patching

Ran this is a dos window under NT.  If the runtime error bug is removed from the program

it should do something else like freeze up or give call the built in error routine I
programed
in it my self years back when I had the source code.

Re:Runtime error 200 with 16bit protected mode


Quote
In article <356C61E6.D105F...@mediaone.net>, kairo  <ka...@mediaone.net> wrote:
>Anyways your patch program didnt work. Any ideas why ?
>The only thing different that happened was the runtime error occured in a different

Did you use the program in the way I advised? What error did you get and
at what address?

Quote

>address than before it was patched.

>Thats interesting on the 16bit thing, but I never looked at an EXE to see if it was
>16 or 8
>bit after compilation.

There is no 8-bit in PC world.

Quote
> Pascal was a good language years ago, but I hate my self
>for
>using it for so long, no one uses it in business anymore mostly school stuff and
>C++ is
>pretty much the standard now. oh well.

If you so much love C then get lost.

Osmo

Re:Runtime error 200 with 16bit protected mode


Quote
In article <356CD644.29449...@mediaone.net>, kairo  <ka...@mediaone.net> wrote:
>Runtime error 200 at 0002:3ECF. after patching
>Runtime error 200 at 000A:310B. before patching

That is pretty strange as the offset should be around 90h. Also the
errors happen in different segments. Does this have anything to do with
the CRT bug or is it some other bug?

Osmo

Re:Runtime error 200 with 16bit protected mode


In article <356CD644.29449...@mediaone.net>, kairo <ka...@mediaone.net>
writes

Quote
>Runtime error 200 at 0002:3ECF. after patching
>Runtime error 200 at 000A:310B. before patching

Seems it is not a problem with the patch you applied as the segment is
different.  

There may well be a problem in *your* code that has only come to light
on fast machines.

Create a map file and that will give the segments. Also use the
find/error (if you can recompile with debug on for the units).
--
Pedt Scragg                    <newsmas...@pedt.demon.co.uk>

Never curse the Crocodile's mother before crossing the river

Re:Runtime error 200 with 16bit protected mode


I cant recompile.  Someone would need to pay me 1 grand for me to go back
and spend a month figuring out how to compile this freaking thing.  To me
its not
worth it.  So from what you are saying the exe is dead.
thanks for the help anyways.

Quote
Pedt Scragg wrote:
> In article <356CD644.29449...@mediaone.net>, kairo <ka...@mediaone.net>
> writes
> >Runtime error 200 at 0002:3ECF. after patching
> >Runtime error 200 at 000A:310B. before patching

> Seems it is not a problem with the patch you applied as the segment is
> different.

> There may well be a problem in *your* code that has only come to light
> on fast machines.

> Create a map file and that will give the segments. Also use the
> find/error (if you can recompile with debug on for the units).
> --
> Pedt Scragg                    <newsmas...@pedt.demon.co.uk>

> Never curse the Crocodile's mother before crossing the river

Re:Runtime error 200 with 16bit protected mode


In article <356DD379.1289D...@mediaone.net>, kairo <ka...@mediaone.net>
writes

Quote
>I cant recompile.  Someone would need to pay me 1 grand for me to go back
>and spend a month figuring out how to compile this freaking thing.  To me
>its not
>worth it.  So from what you are saying the exe is dead.

If you understand assembler code, you could load the program in the
standalone de{*word*81} and look at the code at $000A:$310B

This *may* give you a clue as to why the runerror is occurring.

--
Pedt Scragg                    <newsmas...@pedt.demon.co.uk>

Never curse the Crocodile's mother before crossing the river

Other Threads