Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

Lately I have been Studying some Assembly language, I have a question about the DB Decleration on the .Data Segment of an Assembly Application.

Till Now, I always declared a Byte by doing So:

Number db "Please enter a number : ",0


(Name) db (String), 0

Today, I found an example which had the String Declaration as Follows:

Hello db "Hello World!",13,10, 0


I Have a Question Regarding the 13, 10.

Can anybody point out what these mean.

Thank You,

Andrew Borg
Posted
Comments
Sergey Alexandrovich Kryukov 10-Oct-12 2:46am    
Never heard of 13 10, really? :-)
--SA

:laugh:
They are bytes values added to the end of the string, that cannot be added by normal typing. In this case a carriage return, a line feed and a terminating null character.
In C-type languages, this would be the equivalent of writing:
C++
char* Hello = "Hello World!\n";
It is a good idea to declare these as mnemonics though, so you can use readable names instead of numbers:
Hello db "Hello World!", AS_CR, AS_LF, 0
(I probably wouldn't use AS_NULL for the zero, as it would most likely be a string terminator, rather than a character to display)
 
Share this answer
 
Comments
pasztorpisti 10-Oct-12 4:09am    
+5, but for the clarification of OP its important to note that "Hello World!\n" produces "Hello World",10,0 with all C compilers on all platforms, its just the standard library that interprets the '\n' (10/LineFeed/LF) character and outputs either 10(linux) or 13(mac) or 13,10(DOS/Windows) when writing the string into a stream in TEXT mode (not binary because that doesn't do the conversion!!!). The standard library also does the conversion of these into 10 when reading from a file.
They mean CR LF, Carriage_Return (13), Line_Feed (10). These two bytes together define standard end-of-line delimiter in ASCII (or any one-byte-per-character encodings) in case of Microsoft systems.

(Generally, the end-of-line delimiter is platform-dependent; and this fact used to be a source on numerous confusions, which appear not often, but from time to time even these days.)

—SA
 
Share this answer
 
Comments
pasztorpisti 10-Oct-12 4:10am    
+5
Sergey Alexandrovich Kryukov 10-Oct-12 10:51am    
Thank you :-)
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900