Seite 1 von 1

Transformation von Variable auf Pointer einer Variabel

Verfasst: Do 14. Jun 2018, 22:51
von PIC18F2550
original

Code: Alles auswählen

VAR long dataStructureAddress[0]
  ...
  byte volumeLabel[12], directoryEntryCache[32], dataBlock[512], CIDRegisterCopy[16]
  ...
PRI blockToLong(index) ' 4 Stack Longs
  bytemove(@result, @dataBlock[(index & $1_FF)], 4)
Aus dem Array dataBlock[512] wird ein Pointer PdataBlock auf einen 512 Byte großen Puffer.

Code: Alles auswählen

VAR long dataStructureAddress[0]
  ...
  byte volumeLabel[12], directoryEntryCache[32], dataBlock[512], CIDRegisterCopy[16]
  byte volumeLabel[12], directoryEntryCache[32], CIDRegisterCopy[16]
  word RTCtime, PdataBlock
  ...
PRI blockToLong(index) ' 4 Stack Longs
  bytemove(@result, PdataBlock[(index & $1_FF)], 4)
Ich denke das das so richtig ist was Sagt ihr dazu?

Das ist der Block der umgestellt muss

Code: Alles auswählen


PRI blockToWord(index) ' 4 Stack Longs
  bytemove(@result, @dataBlock[(index & $1_FF)], 2)
  bytemove(@result, PdataBlock[(index & $1_FF)], 2)  ' <<<<< Richtig So?

PRI longToBlock(index, value) ' 5 Stack Longs
  bytemove(@dataBlock[(index & $1_FF)], @value, 4)
  bytemove(PdataBlock[(index & $1_FF)], @value, 4)  ' <<<<< Richtig So?

PRI byteToBlock(index, value) ' 5 Stack Longs
  dataBlock[(index & $1_FF)] := value ' <<<<<< Wie muss ich das Umstellen?
  byte[PdataBlock+(index & $1_FF)] := value ' <<<<<<< Richtig So?

PRI zeroBlock ' 3 Stack Longs
  bytefill(@dataBlock, 0, 512)
  bytefill(PdataBlock, 0, 512)  ' <<<<< Richtig So?

PRI blockToByte(index) ' 4 Stack Longs
  return dataBlock[(index & $1_FF)] ' <<<<<< Wie muss ich das Umstellen?
  return byte(PdataBlock+(index & $1_FF)] ' <<<<<< Richtig So?

PRI addressOfBlock(index) ' 4 Stack Longs
  return @dataBlock[(index & $1_FF)]
  return PdataBlock[(index & $1_FF)]  ' <<<<< Richtig So?


Re: Transformation von Variable auf Pointer einer Variabel

Verfasst: Fr 15. Jun 2018, 14:16
von kuroneko
PIC18F2550 hat geschrieben:Aus dem Array dataBlock[512] wird ein Pointer PdataBlock auf einen 512 Byte großen Puffer.

Code: Alles auswählen

VAR long dataStructureAddress[0]
  ...
  byte volumeLabel[12], directoryEntryCache[32], dataBlock[512], CIDRegisterCopy[16]
  byte volumeLabel[12], directoryEntryCache[32], CIDRegisterCopy[16]
  word RTCtime, PdataBlock
  ...
PRI blockToLong(index) ' 4 Stack Longs
  bytemove(@result, PdataBlock[(index & $1_FF)], 4)
Versuch's mal mit bytemove(@result, PdataBlock + (index & $1_FF), 4) unter der Annahme das PdataBlock == @dataBlock[0] ist. PdataBlock[] gibt dir nur irgendwelche words zurück.

Re: Transformation von Variable auf Pointer einer Variabel

Verfasst: Fr 15. Jun 2018, 22:42
von PIC18F2550
OK kuroneko,

PdataBlock == @dataBlock[0] Da PdataBlock := @dataBlock[0] ist.

Damit ist mir die Wirkungsweise von bytemove ausreichend verständlich.

Direkt Adressierung:
bytemove( @Quelle, @Ziel, Länge)

Indirekte Adressierung über extra Variabeln
PointerQuelle := @Quelle
PointerZiel := @Ziel
bytemove( PointerQuelle, PointerZiel, Länge)

Code: Alles auswählen

PRI byteToBlock(index, value)
  dataBlock[(index & $1_FF)] := value
  byte[PdataBlock+(index & $1_FF)] := value

PRI zeroBlock
  bytefill(@dataBlock, 0, 512)
  bytefill(PdataBlock, 0, 512)

PRI blockToByte(index)
  return dataBlock[(index & $1_FF)]
  return byte(PdataBlock+(index & $1_FF)]

PRI addressOfBlock(index)
  return @dataBlock[(index & $1_FF)]
  return PdataBlock+(index & $1_FF)
So sollte es Stimmen nur beim Letzten return binn ich mit nicht sicher.

Re: Transformation von Variable auf Pointer einer Variabel

Verfasst: Sa 16. Jun 2018, 20:58
von kuroneko
Ich seh im Moment kein Problem. Notfalls einfach testen :)

Re: Transformation von Variable auf Pointer einer Variabel

Verfasst: Sa 16. Jun 2018, 22:05
von PIC18F2550
Danke aber zum Testen ist noch ein ganze Menge zu machen.