Addressing

Started by
1 comment, last by Michalson 22 years ago
I working a section of tight code (right now it runs that section at 40,000,000 times/second, goal is 100,000,000 on an Athlon 1200). What I need to do is create a special purpose jump table. Unfortunately I can't find the syntax that will work. Here's the gist what I'm trying

var P: Pointer;
label CodeAddress;
begin
     Some Code  
CodeAddress:Some Code  
     Some Code  
end;
  
What I've tried to do is P:=CodeAddress , and P:=@CodeAddress and P:=Addr(CodeAddress) , but all of these report an error, assuming that either I'm declaring the label or that I'm trying to redeclare it. (BTW this is all within the same scope). My second problem comes in here:

goto P;
  
This will not work, I could rewrite it in plain asm but is there another way to do it (the asm statement will mess up the optimizer [Delphi Enterprise]) Finally anyone know a way I could declare the array as a constant such that

label CodeAddress1,CodeAddress2;
const CodeAddresses:array[0..1]=(CodeAddress1,CodeAddress2);
  
Edited by - Michalson on March 21, 2002 4:34:07 PM
Advertisement
I''m guessing that the compiler does not support the address-of operator on labels. I did not even know labels existed. I may have known about the goto statement, but had never used it. Probably your best bet would be on the Borland newsgroups in borland.public.delphi.objectpascal.


Steve ''Sly'' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
You can get pointer to label this way:

asm
mov eax, offset SomeCode
mov P,eax
end;

Compiler doesn''t allow you to use goto with pointer. You must use assembler:

asm
jmp P
end;

This topic is closed to new replies.

Advertisement