flat assembler
Message board for the users of flat assembler.
Index
> Windows > String Manipulation Functions |
Author |
|
revolution 09 Sep 2010, 00:51
Nameless wrote: * BTW, All Functions are Working Do you have a test program to check all the functions? I would suggest that you hold off trying to make the functions faster or smaller until you get them all working first. And I also suggest that you write a set of companion test functions to automatically check they still function properly after each change. |
|||
09 Sep 2010, 00:51 |
|
bitRAKE 09 Sep 2010, 04:15
Here are some small ones conforming to Win32 ABI:
Code: strZERO: pop edx ; return address! pop ecx ; count mov al,0 xchg edi,[esp] ; address rep stosb pop edi jmp edx strLEN: pop edx mov al,0 or ecx,-1 xchg edi,[esp] repnz scasb xchg eax,ecx not eax dec eax pop edi jmp edx strCMP: pop edx ; return address pop ecx ; count pop eax ; string one xchg esi,[esp] ; string two xchg eax,edi repe cmpsb xchg eax,edi xchg eax,ecx ; return position and flags pop esi jmp edx strCOPY: pop edx ; return address! pop ecx ; count pop eax ; string one xchg esi,[esp] ; string two xchg eax,edi rep movsb xchg eax,edi pop esi jmp edx (Best to inline instead.) |
|||
09 Sep 2010, 04:15 |
|
revolution 09 Sep 2010, 04:22
bitRAKE: Win32 ABI uses null terminated strings pretty much everywhere. Your code seems to need a count value.
Nameless: Are you aware that the Win32 API already provides string manipulation functions? You are aware that you are reinventing the wheel, right? |
|||
09 Sep 2010, 04:22 |
|
DOS386 09 Sep 2010, 06:03
revolution wrote: Nameless: Are you aware that the Win32 API already provides string manipulation functions? You are aware that you are reinventing the wheel, right? Where is the problem ? More free, more open source, more FASM'ous |
|||
09 Sep 2010, 06:03 |
|
Nameless 09 Sep 2010, 06:20
@revolution:
sorry, fixed Code: proc _strcpy, lpDest, lpSource pusha stdcall _clear_str, [lpDest] mov esi, [lpSource] mov edi, [lpDest] .store_data: lodsb cmp al, byte 0 je .done stosb jmp .store_data .done: mov [edi],byte 0 popa ret endp also if u read the first lines of my topic, im already using those APIs (thats how i got the names), but the thing is, i wanna write my owen in pure ASM @bitRAKE: y is it best to use inline? *i see alot of new instructions in ur code (to me), time to google * |
|||
09 Sep 2010, 06:20 |
|
bitRAKE 09 Sep 2010, 07:23
Nameless wrote: @bitRAKE: y is it best to use inline? Looking at the downside: faster algorithms can be developed with a bias towards strings of a particular average size; different processors have very different performance characteristics for the string instructions. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
09 Sep 2010, 07:23 |
|
Picnic 09 Sep 2010, 11:39
Here's two fasm links,
vid's fasmlib has a basic set of safer string functions. See inside fasmlib-0.8.0/src/str. aaro's dynamic library, old stuff which probably require modifications today. Check inside StrLib.asm plus a tiny one Code: ; strlen() ; in:esi address, out:ecx length strlen: push esi or ecx, -1 @@: inc ecx lodsb test al, al jnz @B pop esi ret |
|||
09 Sep 2010, 11:39 |
|
LocoDelAssembly 09 Sep 2010, 14:25
Code: .store_data: lodsb stosb test al, al jnz .store_data popa ret |
|||
09 Sep 2010, 14:25 |
|
Nameless 09 Sep 2010, 16:57
@Picnic: thanks alot for this code, i got some ideas out of it. ur missing my point here, im trying to make my owen, i wont get better by using other's code (at least thats what i think)
@LocoDelAssembly: kewl , time to learn about test instruction , thanks alot |
|||
09 Sep 2010, 16:57 |
|
mindcooler 10 Sep 2010, 06:17
Code: strlen: ;>esi,<eax xor eax,eax .loop: cmp byte [esi+eax],0 je .out inc eax jmp .loop .out: retn _________________ This is a block of text that can be added to posts you make. |
|||
10 Sep 2010, 06:17 |
|
Nameless 10 Sep 2010, 11:18
awsome
Code: cmp byte [esi+eax],0 this keeps getting better and better with each post YAYYYYYYYYYYYYYYYYYYYYY! |
|||
10 Sep 2010, 11:18 |
|
Picnic 13 Sep 2010, 14:45
Nameless wrote: i wont get better by using other's code (at least thats what i think) Well, i think that often studying other people's code/techniques has benefits. But maybe is not the right way for all. |
|||
13 Sep 2010, 14:45 |
|
Nameless 13 Sep 2010, 17:02
ofc stying other people's code and techniques is very good, but using it blindly isn't a right way at all
|
|||
13 Sep 2010, 17:02 |
|
semiono 15 Sep 2010, 13:16
post 1,2 This all procedures depend on each other? Is it available make it not depend and separatly?
I've grab this code so as lesson for me Thanks! |
|||
15 Sep 2010, 13:16 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.