Forum
× Cross-Build Development for WinCE OS

Question WINCE-CT6 - DCP component; Bus Error or misaligned access

  • Segami Steve
  • Segami Steve's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
3 months 3 weeks ago #10824 by Segami Steve
Segami Steve created the topic: WINCE-CT6 - DCP component; Bus Error or misaligned access
Hi,

I can crypt a string with DCP components and write the result in a file.

The file is a record structure as:
Tconfig = record
Line1: string[50];
Line2: string[50];
Line3: string[50];
end;

Each string is crypted before to write the record in a file.

But if I read the file, when I want to decrypt a crypted string, the result is a "Bus Error or misaligned access"

An idea to resolve this problem?

Thanks and Best Regars

Please Log in or Create an account to join the conversation.

  • Segami Steve
  • Segami Steve's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
1 week 4 days ago #10987 by Segami Steve
Segami Steve replied the topic: WINCE-CT6 - DCP component; Bus Error or misaligned access
To solve the problem:
16-bit and 32-bit values need to be 4-byte aligned in memory. Otherwise bus error will occur!

So, codes of DCP unit must be modified on the base of this example (see "unaligned()"):

...
var
p1: ^Longint;
l: longint;
begin
p1^ := 20; //might cause error if p points to an unaligned memory, i.e. not 4-byte aligned.
unaligned(p1^) := 20; //it is ok
l := pl^; //this can also generate error
l := unaligned(pl^); //it is ok
end.

....

Please Log in or Create an account to join the conversation.