Here is a quick solution.
32bit value swap
Code: Select all
Procedure.l Endian(val.l)
!MOV Eax,dword[p.v_val]
!BSWAP Eax
ProcedureReturn
EndProcedureCode: Select all
Debug Hex(Endian($112233))Code: Select all
CompilerIf #PB_Compiler_Processor=#PB_Processor_x64
	Procedure.q EndianQ(val.q)
	!MOV rax,qword[p.v_val]
	!BSWAP rax
	ProcedureReturn
	EndProcedure
CompilerElse
	Procedure.q EndianQ(val.q)
	!MOV Eax,dword[p.v_val]
	!MOV Edx,dword[p.v_val+4]
	!BSWAP Eax
	!BSWAP Edx
	!MOV dword[p.v_val+4],Eax
	!MOV dword[p.v_val],Edx
	ProcedureReturn val
	EndProcedure
CompilerEndIfCode: Select all
Debug Hex(EndianQ($112233))if you need to convert to/from RGB,BGR or RGBA and ABGR etc.
Or when dealing with network order/Motorola (big endian) values.
EDIT: PB 4.x implementations instead, the older PB 3.x functions moved to the 2nd post.
Sidenote to Fred: Endian() and EndianQ() really need to be native PB commands
Have fun!

