[fpc-pascal] address of a label (possibly stupid question)

Bernd Kreuss prof7bit at googlemail.com
Sun Sep 5 19:59:04 CEST 2010


Hi,

I have a probably stupid question, experienced assembler programmers
will probably laugh but here is my problem:

I am trying to push the address of a label onto the stack but it doesn't
seem to work. __finally is a label and handler is the name of a
function. I can push the address of the function onto the stack without
problem but not that of the label.

The following illustrates the problem, both writelns should output the
same but in the first case with the label it won't. What am I missing?
Is this some near/far thing and how can i force it to be far? or is it
something else? The address should be  004017D5 but it is pushing the
number 00A36458 onto the stack. Why does the same syntax for a function
address work?

{$asmmode intel}

begin
  asm
    push __finally    // this is a label
    pop eax
    mov testus, eax
  end;
  writeln(IntToHex(PtrUInt(testus), 8));
  writeln(IntToHex(PtrUInt(@__finally), 8));

  asm
    push handler     // this is a function
    pop eax
    mov testus, eax
  end;
  writeln(IntToHex(PtrUInt(testus), 8));
  writeln(IntToHex(PtrUInt(@handler), 8));



Z:\Desktop\from_xp\lazproject\SEH>sehtest.exe
00A36458
004017D5
0040B1D0
0040B1D0



More information about the fpc-pascal mailing list