The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ThoughtCriminal on December 04, 2005, 12:21:21 PM

Title: Preappending length to a string with the $ operator
Post by: ThoughtCriminal on December 04, 2005, 12:21:21 PM
I need a reminder how to do this.  Also what a proper newline is.  I think its character codes 0Dh and 0Ah.

Thanks.
Title: Re: Preappending length to a string with the $ operator
Post by: MichaelW on December 04, 2005, 01:05:10 PM
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.

Title: Re: Preappending length to a string with the $ operator
Post by: ThoughtCriminal on December 04, 2005, 01:51:46 PM
Thanks. What I'm trying to get is:

[size]"string"

I seem to remeber its the way PASCAL does strings.

Title: Re: Preappending length to a string with the $ operator
Post by: hutch-- on December 05, 2005, 03:11:59 AM
ThoughtCriminal,

From memory you can allocate an OLE string and it reserves the 4bytes below the address for its size.