[fpc-pascal]Intel ASM syntax problem

Jonas Maebe jonas at zeus.rug.ac.be
Mon Jun 25 17:37:09 CEST 2001


On maandag, juni 25, 2001, at 05:17 , Aitor Santamaria Merino wrote:

>  am trying to compile this (which compiles under TP): (using asm and
> {$ASMMODE Intel}):
>
> (66) mov word ptr ds:ControlBlk25[bx].StartSector,ax
> (67) mov word ptr ds:ControlBlk25[bx].StartSector[2],ax
>
>
> where
>  ControlBlk25  = record   { control block for INT 25 extended call }
>    StartSector : LongInt; { start sector to read }
>    Count       : Word;    { number of sectors to read }
>    BufferOffs  : Word;    { data buffer offset }
>    BufferSeg   : Word;    { data buffer segment }
>  end;
>
>
> The problem appears when it reaches the [bx]:
> drvscan.pp(66,18) Fatal: Syntax error, [ expected but identifier found
>
> Any alternative/correction?

First of all: you will most likely have to rewrite almost all your 
assembler routines, because you now work in a 32bit memory model. This 
means that anything that  uses segments (including lds/les) or memory 
address expressions containing registers (such as the above) will have 
to change. The reason is that there are no segments anymore, only 
selectors (which you normally can ignore, you can assume all of your 
data is in the DS selector, except if you need to access video memory or 
so) and all offsets are 32bits (so you'd need at least ebx instead of bx 
in the above example).

Second, you won't be able to pass a data structure from you program to a 
Dos interrupt call the way you are trying it, because Dos can only work 
with the first megabyte of memory and in segment:offset format, while 
FPC programs work with all memory in your computer and that data 
structure most likely lies way above the first megabyte. You will need 
the dosmemput/dosmemget/global_dos_alloc/global_dos_free routines from 
the go32 unit. I suggest you throughly read the docs of that unit before 
attempting things like this

Third: there may indeed be bugs in the assembler reader. It should 
compile if you change it to

mov word ptr ControlBlk25[ebx].StartSector,ax

but I'm not sure (you definitely need a 32bit register as offset, I 
don't think we support the generation db 67h prefixes to allow 16bit 
registers in memory expressions).


Jonas




More information about the fpc-pascal mailing list