Register for your free account! | Forgot your password?

You last visited: Today at 21:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Hier poste ich ASM und Reversing Zeugs welches ich nicht in einem Thread packen kann, da es sich nicht lohnen würde.
Rate this Entry

Array Rotation

Posted 12/28/2013 at 02:45 by ​Tension
Updated 12/29/2013 at 01:51 by ​Tension

Jo,
Ich brauchte diese Funktion gerade bei einem Projekt.

Code:
p = { 1,2,3,4,5 }; //Das Array
n = 2; //Die Runden
rot_array_l, p, 5, n; //5=Größe des Arrays
p = { 3,4,5,1,2 }; //Das Array nach der Rotation.
ich poste es hier für BYTES, man kann es natürlich auch für WORD- und DWORD-Arrays anpassen sollte ja nicht alt zu schwer sein ( wenn man etwas Assembler kann ).

rot_array_r => Nach Rechts drehen
rot_array_l => Nach Links drehen

Code:
rot_array_r		proc	array:DWORD, len:DWORD, n:DWORD
	LOCAL i:DWORD, j:DWORD, tmp:DWORD
	mov i, 0
	pushad
	@L1:
		pushad
		mov esi, array
		mov ecx, len
		dec ecx
		movzx eax, byte ptr ds:[esi+ecx]
		mov tmp, eax
		mov ecx, len
		dec ecx
		mov j, ecx
		@L2:
			pushad
			mov ecx, j
			dec ecx
			movzx eax, byte ptr ds:[esi+ecx]
			inc ecx
			mov byte ptr ds:[esi+ecx], al
			popad
			dec j
			cmp j, 0
			jg @L2
		mov eax, tmp
		mov byte ptr ds:[esi], al
		popad
		inc i
		mov ecx, n
		cmp i, ecx
		jl @L1
	popad
	ret

rot_array_r endp


rot_array_l		proc	array:DWORD, len:DWORD, n:DWORD
	LOCAL i:DWORD, j:DWORD, tmp:DWORD
	mov i, 0
	pushad
	@L1:
		pushad
		mov esi, array
		movzx eax, byte ptr ds:[esi]
		mov tmp, eax
		mov j, 0
		@L2:
			pushad
			mov ecx, j
			inc ecx
			movzx eax, byte ptr ds:[esi+ecx]
			dec ecx
			mov byte ptr ds:[esi+ecx], al
			popad
			inc j
			mov ecx, len
			dec ecx
			cmp j, ecx
			jl @L2
		mov eax, tmp
		mov ecx, len
		dec ecx
		mov byte ptr ds:[esi+ecx], al
		popad
		inc i
		mov ecx, n
		cmp i, ecx
		jl @L1
	popad
	ret

rot_array_l endp
Anwendung:
Code:
//.data 
// szData  db 'abc',0
invoke rot_array_l, addr szData, 3, 1
Mfg.
Posted in Uncategorized
Views 271 Comments 0 Email Blog Entry
« Prev     Main     Next »
Total Comments 0

Comments

 

All times are GMT +1. The time now is 21:19.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.