Inline Assembler: Invalid reference syntax

100 Views Asked by At

two days ago I got the following error of the Free Pascal Compiler 2.2.0:

Error: Invalid reference syntax

Prehistory:

I wanted to compile a pascal source with some included assembly directives for the platform "i386-linux"

procedure drawpixel(x,y,color: word); assembler;
asm
  mov ax, y
  mov bx, x
  mov dl, color

  mov cx, 320
  mul cx
  add ax, bx
  mov di, ax
  mov [es:di], dl /// Right at [es:di] the inline assembler gives this annoying exception
  ret
end;

Could somebody help me, please.

1

There are 1 best solutions below

0
Marco van de Voort On

As the commentators have already indicated, this is 16-bit assembler which won't work without modification in 32-bit.

Besides that using a 16-bit register for indirect destination ([di]) is weird, the ES segment in 32-bit apps is the same as the DS segment, so probably not what you want (which I assume is supposed to be some mode-X screen buffer), but would ram it somewhere in the first 64kb of application memory, which is at least partially protected against write to trap zero pointer references.

You'll need to rethink this, accessing graphics screens like in dos is not possible in Linux.