Implicit type conversion: Difference between revisions

(Applesoft BASIC)
Line 16:
Indicate if your language supports ''user defined'' type conversion definitions and give an example of such a definition.   (E.g. define an ''implicit type conversion'' from '''real''' to '''complex''' numbers, or from '''char''' to an array of '''char''' of length 1.)
<br><br>
 
=={{header|68000 Assembly}}==
If an instruction operand is smaller than the instruction "length", then it gets typecast to that length.
 
For data registers, the operands are '''not''' sign-extended.
<lang 68000devpac>MOVE.L #$FFFF,D0 ;MOVE.L #$0000FFFF,D0
MOVE.W #$23,D1 ;MOVE.W #$0023,D1
MOVE.W #$80,D2 ;MOVE.W #$0080,D2</lang>
 
The only exception to this is the <code>MOVEQ</code> instruction, which does sign-extend the value.
<lang 68000devpac>MOVEQ #$34,D0 ;MOVE.L #$00000034,D0
MOVEQ #-1,D1 ;MOVE.L #$FFFFFFFF,D1</lang>
 
Address registers mostly work the same way, unless you use <code>MOVEA.W</code>, in which the address ''is sign-extended.''
<lang 68000devpac>MOVEA.L #$A01000,A0 ;assembled as MOVE.L #$00A01000,A0
MOVEA.W #$8000,A1 ;same result as MOVEA.L #$FFFF8000,A1
MOVEA.W #$7FFF,A2 ;same result as MOVEA.L #$00007FFF,A2</lang>
 
=={{header|ALGOL 68}}==
1,489

edits