Seite 2 von 2

Re: Mergesort für Array

Verfasst: 22.12.2019 20:22
von ST4242
P.S.

32 Bit PEEKL(@array()-8)
64 Bit PEEKQ(@array()-16)

Re: Mergesort für Array

Verfasst: 22.12.2019 20:43
von ST4242
Jetzt habe ich noch etwas auf GitHub gesurft, dort steht die structure in C für das Array unter PB.
Dazu ein kleines Programm was unter 32 und 64 Bit funktioniert

Code: Alles auswählen

EnableExplicit

Dim ar.s(15,2,1)


Structure PBArray
  dimensions.i
  elementsize.i
  *point
  *point1
  AnzahlElemente.i
  Datentyp.i
EndStructure

Define *i.PBArray

*i=@ar()-SizeOf(PBArray)
Debug *i\dimensions
Debug *i\point
Debug *i\point1
Debug *i\AnzahlElemente
Debug *i\Datentyp


; typedef struct PB_Array
; {
;   int       NbDimensions;
;   integer   ElementSize;
;   integer  *StructureMap;
;   struct PB_Array **Address;
;   integer   NbElements; // Warning, if you add or change an item, the compiler needs to be modified (for runtime array bound check)
;   int       Type;
; } PB_Array;

Re: Mergesort für Array

Verfasst: 23.12.2019 10:04
von Michael Vogel
Cool, danke

...also bitte eine der folgenden Varianten in die Hauptroutine einsetzen, dann sollte alles klappen

Code: Alles auswählen

Structure ArrayHeaderType
	Dimensions.i
	ElementSize.i
	*Point1
	*Point2
	TotalElements.i
	DataType.i
EndStructure

If \endright<0

	; (1)
	;Protected *ArrayHeader.ArrayHeaderType=*Liste-SizeOf(ArrayHeaderType)
	;\endright=*ArrayHeader\TotalElements/*ArrayHeader\Dimensions-1

	; (2)
	CompilerIf #PB_Compiler_Processor=#PB_Processor_x64
		\endright=PeekQ(*liste-16)-1
	CompilerElse
		\endright=PeekL(*liste-8)-1
	CompilerEndIf

EndIf