Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Source Help

XMM Example

A community discussion post from the original code:zIRON forum.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

XMM Example

hi ,

is there any example of new XMM supporting , please?

http://www.freewebs.com/ogremagic/index.htm

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

at current, there is no xmm support, i have begun adding mmx support, once this is complete i will move onto extended instructions such as sse, sse2 etc

btw welcome back to the forum :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

thanks , i missed Ziron , i am happy to back again.

so , any example of mmx that showing us how to use them , and is it a high_level syntax?

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

for now it is just regular mmx assembly instructions, once i add the whole range of opcodes i may look into adding some high level syntax :)

Colin admin
Posts
928
Threads
49
Location
Bulgaria

just thought i'd update this thread in case others check it, first example can be found here: http://www.codeziron.com/forum.php?page=topic&id=128#post1028

and in the latest beta and new releases will contain a new strlcpy macro which will of course be assembled without any changes to user apps that use strlcpy

//
// Copyright (c) 2012. OverHertz Ltd
//
inline procedure strlcpy(dest, source, len) {
	push edi
	push esi
	push ecx
	
	$if defined(assembler_MMX_ON) == true:
		push edx

		edi = $dest;
		esi = $source;  
		ecx = $len;
		edx = ecx;
	  
		shr ecx, 6
		if (ecx <> 0) {
			repeat {
				movq mm0, qword[esi+0]
				movq mm1, qword[esi+8]
				movq mm2, qword[esi+16]
				movq mm3, qword[esi+24]
				movq mm4, qword[esi+32]
				movq mm5, qword[esi+40]
				movq mm6, qword[esi+48]
				movq mm7, qword[esi+56]
			
				movq qword[edi+0], mm0
				movq qword[edi+8], mm1
				movq qword[edi+16], mm2
				movq qword[edi+24], mm3
				movq qword[edi+32], mm4
				movq qword[edi+40], mm5
				movq qword[edi+48], mm6
				movq qword[edi+56], mm7
			
				esi += 64;
				edi += 64;
			
				edx -= 64;
			
				ecx--;
			} until (ecx == 0);
		}
	  
		ecx = edx;  
		shr ecx, 3
	  
		if (ecx <> 0) {
			repeat {
				movq mm0, qword[esi]
				movq qword[edi], mm0
		
				esi += 8;
				edi += 8;
		
				ecx--;
			} until (ecx == 0);
		}

		ecx = edx;
		and ecx, 3
		rep movsb

		pop edx
		pop ecx
		pop esi
		pop edi
	  
		emms
	$else
		//cld
		edi = $dest;
		esi = $source;
		ecx = $len;
		shr ecx, 2
		rep movsd

		ecx = $len;
		and ecx, 3
		rep movsb

		pop ecx
		pop esi
		pop edi
	$end
}

i will continue to update macros and functions over time so compiled apps will also become faster :)