Literals/String: Difference between revisions

m
Line 72:
{{trans|6502 Assembly}}
Strings are enclosed in double quotes. [[C]] places a null terminator at the end of the string for you; in 68000 Assembly you have to type it manually (unless your assembler has an <code>.ASCIZ</code> directive or equivalent, and not all do).
<lang 68000devpac>DC.B "Hello World",0
EVEN</lang>
Any typed character in double quotes is assembled as the ASCII equivalent of that character. Therefore the following two data blocks are equivalent:
<lang 68000devpac>DC.B "Hello World",0
EVEN
 
DC.B $48,$65,$6c,$6c,$6f,$20,$57,$6f,$72,$6c,$64,$00
EVEN</lang>
 
The assembler typically assumes nothing with regard to special characters. A <code>\n</code> will be interpreted literally, for example. How special characters are handled depends on the printing routine of the hardware's BIOS, or one created byin the programmer.case Ifof yourembedded printinghardware routinewith isno ableBIOS to supportor a nullvery terminatorlimited andone ASCIIlike controlthe codesSega Genesis, the followingprinting representsroutine "Hellocreated World" withby the newprogrammer. lineBy commanddefault, andthere nullis terminator:no support for any control codes unless you add it in yourself.
<lang 68000devpac>DC.B "Hello World",13,10,0
EVEN</lang>
 
=={{header|Ada}}==
1,489

edits