News:

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

DB With Strings

Started by kilicor, April 11, 2007, 10:59:00 PM

Previous topic - Next topic

kilicor

Just a quick question which I couldn't find the answer to in the normal ways-
If I have a .data section in a masm .asm file with the following:
helloWorld db "Hello World", 0What is the purpose of the 0? Is it a null terminator? What else can I put there?
Thanks.

hutch--

To know where the end of the string is you have a couple of choices, store its length in another variable or place a terminating ZERO at the end.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Tedd

Yes, it's jsut a null-terminator (null generally always means zero.)
Zero is the convention for c-style strings, to indicate the end of the string - which is what windows generally uses; prefixing a character array with its length is the pascal standard.
You could put any number (between 0 and 255, inclusive) there - and even many numbers separated by commas - each would be used to represent an ascii character (when "helloworld" is used as an ascii string.)
Other commonly useful values to make note of are: 9 = tab, 13 = carriage-return, 10 = line-feed (standard windows 'newline' is actually "13,10")
No snowflake in an avalanche feels responsible.