Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-06

Intel ASM syntax problem

5 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aitor Santamaria Merino

Hi all,

I 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?

Aitor

Reply by email

Jonas Maebe
to Aitor Santamaria Merino
Aitor Santamaria Merino wrote 20 lines
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

Reply by email

AITOR.SM

Ooops!!
You are entirely right! 32-bit world!

Let me explain something else about this program. This is a piece of snippet taken from SWAG, as it is a quite detailed drive identification code, so I didn't write it myself. I simply tried to compile under FPK, just forgetting that I am doing these seg:ofs calls and the like.

Well, I don't believe this will compile even if I change bx by ebx. My solutions could be:

(a) any of you has a piece of code to detect fd/cd/hd/ram/net disks under GO32V2
(b) as this is a *very* small program, I will compile it under TP (which is a pitty, I expected to release my program entirely compilable under FreePascal)

Well, thanks!
Aitor

Earlier message 83 lines
----- Mensaje Original ----- De: Jonas Maebe Fecha: Lunes, Junio 25, 2001 5:37 pm Asunto: Re: [fpc-pascal]Intel ASM syntax problem > > 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 > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > ___________________________________________________________________ Consigue tu e-mail gratuito TERRA.ES Haz clic en http://www.terra.es/correo/

Reply by email

Marco van de Voort
to AITOR.SM
Show quoted text 8 lines
code, so I didn't write it myself. I simply tried to compile under FPK, just forgetting that I am doing these seg:ofs calls and the like. Well, I don't believe this will compile even if I change bx by ebx. My solutions could be: (a) any of you has a piece of code to detect fd/cd/hd/ram/net disks under GO32V2

Www.stack.nl/~marcov/xtdfpc.htm

Download xtdfpc[xx].zip and check unit edos.

Reply by email

Unknown author
to AITOR.SM: Ooops!! You are entirely right! 32-bit world! Let me explain something else about this…

From: "AITOR.SM"
To:
Date sent: Mon, 25 Jun 2001 23:11:00 +0200
Subject: Re: [fpc-pascal]Intel ASM syntax problem Send reply to:

(a) any of you has a piece of code to detect fd/cd/hd/ram/net disks under GO32V2

Not directly, but I have code compilable for Borland 16-bit protected mode extender (as well as plain real mode and Win 3.x) and this one should be quite easy to add support for 32-bit (most things were already rewritten from pure assembler to Pascal for the protected mode support). You can download it from
http://www.volweb.cz/xhajt03/drvtyp13.zip.

Have a nice day

Tomas Hajny

Reply by email