Literals/String: Difference between revisions

m
Line 78:
<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
Line 84 ⟶ 85:
DC.B $48,$65,$6c,$6c,$6f,$20,$57,$6f,$72,$6c,$64,$00
EVEN</lang>
 
When using a string literal as an operand for an instruction, it must begin with #, otherwise it will be treated as a pointer being dereferenced rather than the numeric constant you intended.
 
<lang 68000devpac>MOVE.L #'SEGA',D0 ;load the string "SEGA" into D0
MOVE.L '0000',D0 ;load the 32-bit value at address 0x00303030 (the most significant byte is always treated as zero,
;because the 68000 only has a 24-bit address space.</lang>
 
The assembler typically assumes nothing with regard to special characters. How special characters are handled depends on the printing routine of the hardware's BIOS, or in the case of embedded hardware with no BIOS or a very limited one like the Sega Genesis, the printing routine created by the programmer. By default, there is no support for any control codes unless you add it in yourself.
1,489

edits