Problem mit Longword?

  • 1
  • 2
  • Page 1 of 2
dr.boost
 
Avatar
 
Subject:

Problem mit Longword?

 · 
Posted: 11.04.2011 - 10:52  ·  #1
Hallo.

Ich habe ein Problem mit der Longword-Variable. Ich möchte sie nutzen um auf 32 einzelne Bits zugreifen zu können. Dazu mache ich folgende Deklaration:
var
lw:longword;
test[@lw,0]:bit; //Das funktioniert noch
...
begin
if bit (test) then //alternativ "if test" oder "if not test"
...
endif;
end. //Erzeugt im Compiler den Fehler "not implemented"

incl(test) bzw. excl(test) funktioniert.

Laut Handbuch sollte die Longword-Variable für Bit-Operationen geeignet sein und scheint ja auch teilweise so zu sein. Ich behelfe mir, indem ich 2 Word-Variablen nehme. Damit funktioniert es problemlos. Ist aber an anderer Stelle im Programm umständlicher zu handhaben. Ich habe auch schon mal probehalber das Longword aus dem System importiert (From system import: Longword;), hat aber auch nicht geholfen. Ich verwende die Professional-Version in der neuesten Release.
Habe ich da einen Denkfehler?
Viele Grüße
O.Kolbe
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: Problem mit Longword?

 · 
Posted: 11.04.2011 - 14:57  ·  #2
Is your variable global or not global? Bit() works only with global. Have you tried simple:
Code
if test then
  ..
endif;

or 
Code
if Bit(lw, 0) then // longword only with AvrCo version 4
  ..
endif;

If you have old AvrCo then you can have 4 byte variables or 2 word variables point to longword, and then you can test corresponding bit.
dr.boost
 
Avatar
 
Subject:

Re: Problem mit Longword?

 · 
Posted: 11.04.2011 - 15:32  ·  #3
Hi Avra.

Yes, it's a global variable. Yes, I tried the simple form (my prefered form). I'm using AVRCo V4, latest release.
mc-electronic
Benutzer
Avatar
Gender: n/a
Location: Sauerland NRW
Posts: 372
Registered: 03 / 2008
Subject:

Re: Problem mit Longword?

 · 
Posted: 11.04.2011 - 18:20  ·  #4
Hi DrBoost,

I tried your sample and various ways of making it work, it didn't. As you say, with Word it works, with LongWord it doesn't.
I think, this could be a little bug in the compiler.

Regards, Michael
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: Problem mit Longword?

 · 
Posted: 11.04.2011 - 19:37  ·  #5
I agree - a bug, but here is a work-around:

Code
var
  lw : longword;
  lw1[ @lw ] : word;
  test[ @lw1, 0 ] : bit;


Regards

Merlin.
dr.boost
 
Avatar
 
Subject:

Re: Problem mit Longword?

 · 
Posted: 12.04.2011 - 09:10  ·  #6
Thanks Merlin.

I will try it this evening.

Regards

Olaf
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: Problem mit Longword?

 · 
Posted: 12.04.2011 - 14:39  ·  #7
That is exactly what I said here:
Quote
If you have old AvrCo then you can have 4 byte variables or 2 word variables point to longword, and then you can test corresponding bit.
mc-electronic
Benutzer
Avatar
Gender: n/a
Location: Sauerland NRW
Posts: 372
Registered: 03 / 2008
Subject:

Re: Problem mit Longword?

 · 
Posted: 12.04.2011 - 15:07  ·  #8
Hi Avra,

I have the latest version and there it also does not work with longword, just word. I think, this is something for Rolf. So, the matter is not confined to the older 4xx versions.

Cheers, Michael
  • 1
  • 2
  • Page 1 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   121   135 · Page-Gen-Time: 0.028347s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI