[fpc-pascal]runtime 201 with swapword function
Matt Emson
memsom at interalpha.co.uk
Fri Jul 25 17:36:39 CEST 2003
Doesn't system contain a routine called 'swap' that does this exact thing??
This program would seem to work in both Delphi and FPC1.1:
program test;
{$APPTYPE CONSOLE}
uses
sysutils;
var
i, j: word;
begin
i := $9988;
writeln( IntToHex(i, 4) ); //output '9988'
j := swap( i );
writeln( IntToHex(j, 4)); //output '8899'
readln;
end.
No need to go to the trouble of writing your won routine!! ;-)
Matt
> Hi,
>
> Why does the following result in a runtime error ?
>
> program example;
>
> const
> THE_PORT = 9999;
>
> function swapWord(w: Word): Word;
> begin
> swapWord := (w SHL 8) OR (w SHR 8);
> end;
>
> var
> port: Word;
> begin
> port := swapWord(THE_PORT)
> end.
>
> $ ./swapword
> Runtime error 201 at 0x08052AA2
> 0x08052AA2
> 0x08052AC2
> 0x080480B0
>
>
> cheers
> James
>
> --
> -
> -Zero Defect Software Engineers Group - ZDSEG
> -
> -You need only two tools. WD-40 and duct tape.
> -If it doesn't move and it should, use WD-40.
> -If it moves and shouldn't, use the tape.
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list