[fpc-pascal] FPC in DOS environment

Daniel Franzini daniel.franzini at gmail.com
Wed Jan 10 20:09:50 CET 2007


Hi all

i'm trying to use fpc in a old DOS environment by using FreeDOS inside
Virtual PC (guess i should be using vmware)

the problem is that i have some low-level code which i would like to port to
fpc. FreeDOS came with fpc 2.0.2 which i think is suitable for my needs.

1.) i can't even compile the code
----------------------start-------------------------------
C:\>cd
code
C:\code>fpc diskexp.pas

An unhandled exception occurred at $0001072C
:
EAccessViolation : Access
violation

$0001072C


$00010752


$00010CC0


$00010D13


$000100A8


$00006E8F


$00006ED0


$000022E3


$0000279E

----------------------------end------------------------

the strange thing is that if i call fpc without parameters the (huge) usage
shows up correctly...is fpc for go32v2 a pmode app? which extender do you
recommend me to use?

2.) i have some questions regarding pmode programming with fpc since i never
used go32v2. with cwsdpmi, one compiles and links, getting an exe and this
exe should be put in the same folder of cwsdpmi.exe. what's the general
procedure for go32v2?

3.) in other machine i tried and compiled the code but got some strange
results (i can post as soon as a i get home and reach that machine). here is
the code:
-------------------------------------------code
start---------------------------------------------------------------------------
program DiskExplorer;

uses crt, dos;

const
        BUFLEN = 4608;
        BUFSECT = 9;
        COMMANDX = 1;
        COMMANDY = 20;
        COMMAND_RT = 79;
        COMMAND_BOT = 24;
        STATUSX = 1;
        STATUSY = 18;
        STATUS_RT = 79;
        STATUS_BOT = 19;
        LEFTSCREEN = 1;
        RIGHTSCREEN = 80;
        TOPSCREEN = 1;
        BOTTOMSCREEN = 17;
        ERROR = -1;

type
        buf = array[0..BUFLEN] of byte;

var
        finished: boolean;
        drive: byte;
        sector: integer;
        buffer: buf;
        regs: Registers;

function DiskRead(drive: byte; sector, n_sectors: integer; var buffer: buf):
integer;
begin
        inline($55/
{this assembly code does nothing more than saving correct stuff, executes
DOS}
               $8B/$EC/
{interrupts for read/write the disk, restores stuff, flushes DOS buffer and
exits     }
               $83/$C5/$08/
               $1E/
               $8B/$5E/$00/
               $8B/$46/$02/
               $8E/$D8/
               $8B/$4E/$04/
               $8B/$56/$06/
               $8A/$46/$08/
               $55/
               $CD/$25/
               $73/$08/
               $9D/
               $5D/
               $89/$46/$0A/
               $EB/$08/$90/
               $9D/
               $5D/
               $33/$C0/
               $89/$46/$0A/
               $1F/
               $5D);
end;


function DiskWrite(drive: byte; sector, n_sectors: integer; var buffer:
buf): integer;
begin
        inline($55/
               $8B/$EC/
               $83/$C5/$08/
               $1E/
               $8B/$5E/$00/
               $8B/$46/$02/
               $8E/$D8/
               $8B/$4E/$04/
               $8B/$56/$06/
               $8A/$46/$08/
               $55/
               $CD/$26/
               $73/$08/
               $9D/
               $5D/
               $89/$46/$0A/
               $EB/$08/$90/
               $9D/
               $5D/
               $33/$C0/
               $89/$46/$0A/
               $1F/
               $5D);
        regs.ax := $D00;
        intr($21, regs);
end;


procedure Beep;
begin
        sound(400);
        delay(500);
        sound(300);
        delay(500);
        nosound;
end;

procedure DisplayStartScreen;
begin
        clrscr;
        window(1,1,80,25);
        writeln('=================Disk Examiner=================');
        writeln;
        writeln;
        writeln;
        writeln;
        writeln('-------------------MAIN MENU-------------------');
        writeln('F1: Dump and modify sectors');
        writeln;
        writeln('F10: Exit');
end;


{ main routine }
begin
        drive := 0;
        sector := 0;
        finished := false;
        while not finished do
        begin
                DisplayStartScreen;
                regs.ax := 0;
                intr($16, regs);
                if regs.ax and $ff = 0 then
                begin
                        clrscr;
                        case (regs.ax) of
                                $4400: finished := true;
                        end;
                end;
        end;
end.
-------------------------------------------code
end---------------------------------------------------------------------------

this code compiles fine with tp5.5 (altough the window function does not
work)...what is the correct way to make such a thing in fpc?!

how to mix assembly with fpc in the same procedure/function? i tried but it
complained about the labels



-- 
Daniel

"Let us change our traditional attitude to the construction of programs.
Instead of imagining that our main task is to instruct a computer what to
do, let us concentrate rather on explaining to human beings what we want a
computer to do." (Donald Knuth)

"Yes, technogeeks can be funny, even if only to each other." (
http://www.boogieonline.com/revolution/science/humor/)"

"Man is driven to create; I know I really love to create things. And while
I'm not good at painting, drawing, or music, I can write software."
(Yukihiro Matsumoto, a.k.a. ``Matz'')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20070110/9c6b386b/attachment.html>


More information about the fpc-pascal mailing list