Recent

Author Topic: Byte Manipulation  (Read 14189 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Byte Manipulation
« Reply #15 on: February 11, 2015, 02:15:46 pm »
Older Delphi versions always add Windows and Messages. I guess the tool doesn't scan for windows functions but just assumes it is a useless (because usually it is).


flywire

  • Jr. Member
  • **
  • Posts: 85
Re: Byte Manipulation
« Reply #16 on: February 13, 2015, 12:43:47 pm »
Certainly the windows clause seems to be needed if LoByte, LoWord, HiByte, Hiword are used. Except for the advice of GetMem I had no idea what was going on.

BeniBela

  • Hero Member
  • *****
  • Posts: 906
    • homepage
Re: Byte Manipulation
« Reply #17 on: February 13, 2015, 10:37:19 pm »

Older ARMs, and some of the more embedded ARMs inherit this.

Is there a list of devices names with are those?

Is it always when FPC_REQUIRES_PROPER_ALIGNMENT is set, or is that just always set on ARM?

I just noticed that fpc added a lot of

Code: [Select]
function AlignToPtr(const p: Pointer): Pointer;
 begin
 {$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
   Result := Align(p, SizeOf(Pointer));
 {$ELSE}
   Result := p;
 {$ENDIF}
 end;

to Sorokin's regexpr library, while I still use the original library without that. And a few people say it had crashed on their smart phone, while it has never happened in the emulator.



FPK

  • Moderator
  • Full Member
  • *****
  • Posts: 118
Re: Byte Manipulation
« Reply #18 on: February 14, 2015, 10:51:17 am »
That can be easily seen because my use (written from memory) is different from the manual, the doc seem to indicate that you need to put unaligned over the pointer (the @ expression). At least according to docs.

Then the docs are wrong. Unaligned/Aligned take an expression and the access to this expression is done unaligned. Marking the pointer pointing to an unaligned address would require a lot of ugly code like:

Unaligned(@a)^

Quote
In general even large parts of packages/ are not ready for this.

In general yes, but the compiler assumes also unaligned for all fields/elements of packed data structures. This covers most cases.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Byte Manipulation
« Reply #19 on: February 14, 2015, 02:25:43 pm »
In general yes, but the compiler assumes also unaligned for all fields/elements of packed data structures. This covers most cases.

Hmm, is that in the docs? Maybe the whole alignment business warrants its own paragraph in the prog guide or so

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Byte Manipulation
« Reply #20 on: February 14, 2015, 08:48:12 pm »
I used to write unaligned() a lot in WinCE a long time ago, usually not by actively thinking about it but just fixing places where it crashed with Bus Error exception. But since then it looks like that both FPC and ARM improved a lot (I remember vaguely reading the FPC improve its own auto-detection of unaligned access), and while writing recently for WinCE and for Android I don't quite remember using unaligned at all, maybe only once or twice...
« Last Edit: February 14, 2015, 08:59:10 pm by felipemdc »

FPK

  • Moderator
  • Full Member
  • *****
  • Posts: 118
Re: Byte Manipulation
« Reply #21 on: February 15, 2015, 09:52:21 am »
In general yes, but the compiler assumes also unaligned for all fields/elements of packed data structures. This covers most cases.

Hmm, is that in the docs? Maybe the whole alignment business warrants its own paragraph in the prog guide or so

Not sure. You know who you should ask about this :)

coradi

  • Full Member
  • ***
  • Posts: 148
Re: Byte Manipulation
« Reply #22 on: February 15, 2015, 01:12:27 pm »
it would be nice, if there will be a bigger community for ARM, so that we can use STM32F2 F4 and so on and provide Driver (Units) for Displays, Multiplexer and so on!
HiByte and LowByte would be a good beginnign for this :-)
And a extra Threat only with Unitss for µc Units :-)
Amstrad Schneider CPC 6128
AVR8/ARM(STM32)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Byte Manipulation
« Reply #23 on: February 15, 2015, 02:16:26 pm »
I added a note to the existing section in the ref guide.

 

TinyPortal © 2005-2018