Welcome, Guest
Username: Password: Remember me
CodeTyphon Cross-Build Development, discussions and problems
  • Page:
  • 1

TOPIC:

WINCE-CT6 - DCP component; Bus Error or misaligned access 6 years 10 months ago #10824

  • Segami Steve
  • Segami Steve's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 16
  • Thank you received: 0
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.

WINCE-CT6 - DCP component; Bus Error or misaligned access 6 years 7 months ago #10987

  • Segami Steve
  • Segami Steve's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 16
  • Thank you received: 0
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.

  • Page:
  • 1