flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > QUESTION : How can I make this macro work? |
Author |
|
xanatose 25 Jun 2005, 04:24
Found the error. But could not find a way to delete the post.
I was using lenof.szName instead of lenof.#szLen For the curious the code: Code: ;==================================================== ; Creates a constant string ; ; This will create both a label to the string and a variable szName.size for its size. ; ; Must be used in the constant section. ; ; The size of the string does not include the NUL character at the end of it, ; ; @param szName Name of the label of the string ; @param szString String macro cstring szName,[szString] { common label szName forward db szString lenof.#szName equ $ - szName db 0 } ;==================================================== ; Copies a constant string to an area of Memory ; ; @param szText label of the constant string ; @param edi points to destination ; @affects esi edi ecx ; @note User is reponsible of adding the NUL character at the end of the string macro cstring_cpy szText { local szLen local bRemain local nDwords szLen = lenof.#szText ; Length of string ; Do we need to do anything at all? if szLen > 0 ; Yes, if we are here. mov esi,szText ; Set pointer ; Number of dwords to move nDwords = szLen / 4 ; we use rep movsd if we have at least 4 dwords if nDwords > 3 mov ecx,szLen / 4 ; Number of dwords to move rep movsd ; move them else if nDwords > 2 ; 3 dwords movsd movsd movsd else if nDwords > 1 ; 2 dwords movsd movsd else if nDwords > 0 ; 1 dword movsd end if bRemain = szLen and 3 ; Remaining bytes ; Do we need to move 3 bytes? if bRemain > 2 ; Move 3 bytes movsw movsb else if bRemain > 1 ; Do we need to move 2 bytes? ; Move 2 bytes movsw else if bRemain > 0 ; Do we need to move 1 byte? ; Move 1 byte movsb end if end if } |
|||
25 Jun 2005, 04:24 |
|
madmatt 25 Jun 2005, 05:55
Hi, xanatose
I'm not an expert on Fasm marcros, but I think this line in your macro code: Code: lenof.#szName equ $ - szName Should be Code: lenof#.#szName equ $ - szName I think it will work like you want it to then. |
|||
25 Jun 2005, 05:55 |
|
Tomasz Grysztar 25 Jun 2005, 10:04
madmatt: this second hash doesn't matter here.
|
|||
25 Jun 2005, 10:04 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.