Hi Chris,
Almost!
Our Macros are a bit like subs:
' Declaration of VM_Risc markers
MACRO VM_RISC_BEGIN() DB &HEB, &H08, &H56, &H4D, &H42, &H45, &H47, &H49, &H4E, &H31
MACRO VM_RISC_END() DB &HEB, &H08, &H56, &H4D, &H45, &H4E, &H44, &H31, &H00, &H00
The ebx register must be preserved for global use.
asm is fully integrated with o2basic, so no plings required.
this code is okay for 32bit compiling but requires 64bit variables and 64bit register usage for pointers.
FUNCTION CRepFNV32(BYVAL dwOffset AS DWORD, BYVAL dwLen AS DWORD, _
BYVAL offset_basis AS DWORD) AS QUAD
' Exits function if string len = 0 otherwise can GPF Aug 1 2017
IF dwLen = 0 THEN
FUNCTION = 0
EXIT FUNCTION
END IF
'#REGISTER NONE
sys mebx
mov mebx,ebx 'save ebx register, all globals use it, ebp is used by all locals
'
mov esi, dwOffset ;esi = ptr to buffer
mov ecx, dwLen ;ecx = length of buffer (counter)
mov eax, offset_basis ;set to 0 for FNV-0, or 2166136261 for FNV-1
mov edi, &h01000193 ;FNV_32_PRIME = 16777619
xor ebx, ebx ;ebx = 0
nextbyte:
mul edi ;eax = eax * FNV_32_PRIME
mov bl, [esi] ;bl = byte from esi
xor eax, ebx ;al = al xor bl
inc esi ;esi = esi + 1 (buffer pos)
dec ecx ;ecx = ecx - 1 (counter)
jnz nextbyte ;if ecx is 0, jmp to NextByte
mov FUNCTION, eax ;else, function = eax
'
mov ebx,mebx 'retore ebx register
'
END FUNCTION