- 1) FB takes care of the memory management and
2) I don't know a faster and easier way to access a single byte than an indexed string access
Well, behind the scenes, its exactly the same as a Byte-Array access.grindstone wrote:I like to misappropriate strings as byte arrays ...
Code: Select all
Dim Shared As String * 256 table
Code: Select all
Dim Shared As String table
table = String(256,Chr(0)) 'allocate the memory and fill with "0"s
MrSwiss wrote:Well, behind the scenes, its exactly the same as a Byte-Array access.grindstone wrote:I like to misappropriate strings as byte arrays ...
Code: Select all
Dim value as long= &hFFFF0000
dim rev as long = value XOR &hFFFFFFFF
print hex(value,8), hex(rev,8)
sleep
Code: Select all
'bitweise gespiegelt (abcde... -> ...edcba)
#Macro mirror8(Variable)
Asm
mov al, [Variable]
mov bl, 0
mov cl, 8
1:
rcr al
rcl bl
dec cl
jnz 1b
mov [Variable], bl
End Asm
#EndMacro
Dim As UByte zahl = &b00111011
Print Bin(zahl, 8), zahl
mirror8(zahl)
Print Bin(zahl, 8), zahl
mirror8(zahl)
Print Bin(zahl, 8), zahl
Sleep
fxm wrote:MrSwiss wrote:Well, behind the scenes, its exactly the same as a Byte-Array access.grindstone wrote:I like to misappropriate strings as byte arrays ...
Execution time is equivalent if one does not compile with option -exx.
MrSwiss wrote:@Luis,
assembly language may be faster but, on the other hand, less compatible:
you'd have to do separate ASM routines for FBC 32bit and FBC 64bit.
With routines written in FB, you are able to use any of the compilers.
You'll have to decide on which option to choose.
MrSwiss wrote:Just coded an Endian-Inverter for 64bit INT ...
64bit conversion Big-/Little- Endian (here)
This is however, a Byte by Byte conversion (not bit by bit).
Users browsing this forum: No registered users and 11 guests