Implicit type conversion: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 16: | 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.) |
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> |
<br><br> |
||
=={{header|6502 Assembly}}== |
|||
There is no implicit type conversion in the "modern" sense. However, you are free to interpret any bit pattern to mean whatever you want, when you want. A few language constructs help with this. |
|||
The X and Y registers can be used as loop counters, or as an indexed offset into memory. It's very common for both to be true in the same procedure. |
|||
<lang 6502asm>memcpy: |
|||
LDA ($00),y ;load from (the address stored at $0000) + y |
|||
STA ($02),y ;write to (the address stored at $0002) + y |
|||
iny |
|||
bne memcpy ;loop until y = 0 |
|||
rts</lang> |
|||
Any 16-bit value stored at a pair of consecutive zero-page memory addresses can be treated as a pointer to memory. The above example demonstrated this with the use of <code>($nn),y</code>. |
|||
=={{header|68000 Assembly}}== |
=={{header|68000 Assembly}}== |