Literals/String: Difference between revisions

Line 68:
iny
jmp PrintString ;jump back to top. Notice that neither the backslash nor the character after it were actually printed.</lang>
 
=={{header|68000 Assembly}}==
{{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"
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"
EVEN
 
DC.B $48,$65,$6c,$6c,$6f,$20,$57,$6f,$72,$6c,$64
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 by the programmer. If your printing routine is able to support a null terminator and ASCII control codes, the following represents "Hello World" with the new line command and null terminator:
<lang 68000devpac>DC.B "Hello World",13,10,0
EVEN</lang>
 
=={{header|Ada}}==
1,489

edits