News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Preappending length to a string with the $ operator

Started by ThoughtCriminal, December 04, 2005, 12:21:21 PM

Previous topic - Next topic

ThoughtCriminal

I need a reminder how to do this.  Also what a proper newline is.  I think its character codes 0Dh and 0Ah.

Thanks.

MichaelW

If I correctly understand "preappending" to mean that the length precedes the string, I can't think of any non-clumsy method of using the $ operator. All three of these methods return the length of the string:

strlen1 dd SIZEOF astring
strlen2 dd endofstring - astring
astring db "my other brother darryl",13,10,0
endofstring equ $
strlen3 dd $ - astring


As a newline, for stdout (WriteFile, and I think also WriteConsole), and for at least most of the CRT display functions, you can use a LF or a CRLF. A MessageBox seems to accept either or both.

eschew obfuscation

ThoughtCriminal

Thanks. What I'm trying to get is:

[size]"string"

I seem to remeber its the way PASCAL does strings.


hutch--

ThoughtCriminal,

From memory you can allocate an OLE string and it reserves the 4bytes below the address for its size.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php