AtomSoft
Well-Known Member
Hey, i have 2 huge 512 byte buffers and need to copy certain data from BufferA to BufferB. I thought a simple
buffa[x] = buffb[y];
would have worked but i get varying results.
This is partial bufferB
This is partial buffA which is items from buffb i need.
This is the code im using to copy items from buffb to buffa:
x and y are "unsigned int" Both start at 0x00.
Since each buff is 512 bytes and what i need to get from buffb is in 64 byte parts. I only need some of the 64 bytes not all so i copy from buffb all the bytes i need into buffa (data) then i add 64 to y at the end so i get the next 64 bytes.
Be aware y never changes until the y+=64; at the end.
buffa[x] = buffb[y];
would have worked but i get varying results.
This is partial bufferB
Code:
C00 [0] 'A' 0x41 65 01000001
C01 [1] 'J' 0x4A 74 01001010
C02 [2] '.' 0x00 0 00000000
C03 [3] 'a' 0x61 97 01100001
C04 [4] '.' 0x00 0 00000000
C05 [5] 's' 0x73 115 01110011
C06 [6] '.' 0x00 0 00000000
C07 [7] 'o' 0x6F 111 01101111
C08 [8] '.' 0x00 0 00000000
C09 [9] 'n' 0x6E 110 01101110
C0A [10] '.' 0x00 0 00000000
C0B [11] '.' 0x0F 15 00001111
C0C [12] '.' 0x00 0 00000000
C0D [13] 'j' 0x6A 106 01101010
This is partial buffA which is items from buffb i need.
Code:
A00 [0] 'A' 0x41 65 01000001
A01 [1] 'J' 0x4A 74 01001010
A02 [2] 's' 0x73 115 01110011
A03 [3] 'a' 0x61 97 01100001
A04 [4] 'n' 0x6E 110 01101110
A05 [5] '.' 0x2E 46 00101110
A06 [6] '.' 0x00 0 00000000
A07 [7] 'x' 0x78 120 01111000
A08 [8] 't' 0x74 116 01110100
A09 [9] '.' 0x00 0 00000000
A0A [10] '.' 0x00 0 00000000
A0B [11] '.' 0xFF 255 11111111
A0C [12] '.' 0xFF 255 11111111
A0D [13] 'L' 0x4C 76 01001100
This is the code im using to copy items from buffb to buffa:
x and y are "unsigned int" Both start at 0x00.
Since each buff is 512 bytes and what i need to get from buffb is in 64 byte parts. I only need some of the 64 bytes not all so i copy from buffb all the bytes i need into buffa (data) then i add 64 to y at the end so i get the next 64 bytes.
Be aware y never changes until the y+=64; at the end.
Code:
while(1){
if(buffer[y] == 0x00)
break;
data[x++] = buffer[(y+1)];
data[x++] = buffer[(y+3)];
data[x++] = buffer[(y+5)];
data[x++] = buffer[(y+7)];
data[x++] = buffer[(y+9)];
data[x++] = buffer[(y+14)];
data[x++] = buffer[(y+16)];
data[x++] = buffer[(y+18)];
data[x++] = buffer[(y+20)];
data[x++] = buffer[(y+22)];
data[x++] = buffer[(y+24)];
data[x++] = buffer[(y+28)];
data[x++] = buffer[(y+30)];
y+=64;
}
Last edited: