Sign in Join

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

Mailing lists / fpc-pascal / 2010-09

address of a label (possibly stupid question)

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Bernd Kreuss

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

Reply by email