Var: Byte absolute CSeg:$... 
Author Message
 Var: Byte absolute CSeg:$...

Hi, I need help....

My Turbo Pascal 7.0 Compiler doesn't want this code:

Var
    ProgramStart: Byte absolute Cseg:$180;
...

It doesn't like Cseg. I get error 133: cannot evaluate this expression
What does that mean, how can I read out CS during my var declaration.

i am sorry for my english, but ... well ... we do not learn much of it
at school.

THANX
Martin



Wed, 18 Jun 1902 08:00:00 GMT  
 Var: Byte absolute CSeg:$...

Quote:

> My Turbo Pascal 7.0 Compiler doesn't want this code:

> Var
>     ProgramStart: Byte absolute Cseg:$180;
> ...

> It doesn't like Cseg. I get error 133: cannot evaluate this expression
> What does that mean, how can I read out CS during my var declaration.

Cseg contains the value of the cs register, which is the segment value of
the current code segment. The compiler cannot know in which segment your
program will be located.

You must proceed as follows:

var
  ProgramStart : ^byte;
begin
  ProgramStart := ptr(cseg, $180)
end.

You can then access the byte at cs:180h using ProgramStart^.



Wed, 18 Jun 1902 08:00:00 GMT  
 Var: Byte absolute CSeg:$...

Quote:

>Hi, I need help....

>My Turbo Pascal 7.0 Compiler doesn't want this code:

>Var
>    ProgramStart: Byte absolute Cseg:$180;
>...

>It doesn't like Cseg. I get error 133: cannot evaluate this expression
>What does that mean, how can I read out CS during my var declaration.

>i am sorry for my english, but ... well ... we do not learn much of it
>at school.

It would be nice to know what you intend to do. You could define a
pointer and assign Ptr(Cseg,$180) to it.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 Var: Byte absolute CSeg:$...


CSEG is a function,
# Returns the CURRENT value of the CS register
# Remarks:
# The result of type Word is the segment address of the code segment
# WITHIN WHICH CSeg WAS CALLED.
# (from BP help file)

It can`t be evaluated during compilation. You may use following:

Var
    ProgramStart: ^Byte;
Begin
ProgramStart:=ptr(Cseg,$180);

Quote:
>Var
>    ProgramStart: Byte absolute Cseg:$180;
>...
>It doesn't like Cseg. I get error 133: cannot evaluate this expression
>What does that mean, how can I read out CS during my var declaration.

Sandman4

ICQ#59106801
Cc`s greatly appreciated (poor nntp server).



Wed, 18 Jun 1902 08:00:00 GMT  
 Var: Byte absolute CSeg:$...


Quote:
>Hi, I need help....

>My Turbo Pascal 7.0 Compiler doesn't want this code:

>Var
>    ProgramStart: Byte absolute Cseg:$180;
>...

>It doesn't like Cseg. I get error 133: cannot evaluate this expression
>What does that mean, how can I read out CS during my var declaration.

Since version 4, Turbo Pascal has had a separate code segment for
every unit. You would want to know which unit's code segment you were
talking about, and then how would you arrange to have something at
offset $180 in that segment? Any procedures or functions you have in
your main program module will move the start address of the program.

Should that be $100? And if so, you need TP 3.

The start address of the program was at a fixed offset in TP 3,
because that compiler generated .COM files. And there was only one
code segment so, I don't recall but maybe the compiler could have
accepted the absolute statement you give here. But this is no longer
true.

FP



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Dos Time absolute byte?

2. Var Word to Var String

3. newbee question,string var to char var

4. Converting pascal 6-byte reals to C 8-byte doubles

5. Converting pascal 6-byte reals to C 8-byte doubles

6. char - byte or byte - char

7. Byte by byte read into variables...HOW?

8. Converting Bytes(?) to Int / Int to Bytes

9. Byte by byte read into variables...HOW?

10. Help: 16 bytes size Paradox Bytes fields

11. Absolute Basics on Delphi and ADO

12. Absolute Basics on Delphi and ADO

 

 
Powered by phpBB® Forum Software