Generic swap: Difference between revisions
Content added Content deleted
(Generic swap in Tiny BASIC) |
Puppydrum64 (talk | contribs) |
||
Line 102: | Line 102: | ||
ply ;y=#$44 |
ply ;y=#$44 |
||
plx ;x=#$33</lang> |
plx ;x=#$33</lang> |
||
=={{header|68000 Assembly}}== |
|||
Two registers can be swapped with <code>EXG</code>: |
|||
<lang 68000devpac>EXG D0,D1 ;swap the contents of D0 and D1 |
|||
EXG A0,A1 ;swap the contents of A0 and A1</lang> |
|||
However, these commands cannot be used with memory. If you want to do that you'll need to use the stack or a data register. |
|||
<lang 68000devpac>MOVE.L ($00FF0000),D0 |
|||
MOVE.L ($00FF1000),D1 |
|||
MOVE.L D0,($00FF1000) |
|||
MOVE.L D1,($00FF0000)</lang> |
|||
The <code>SWAP</code> switches the high and low words of a data register. It can't be used with memory either. |
|||
<lang 68000devpac>MOVE.L #$1234ABCD,D0 |
|||
SWAP D0 ;now D0 = #$ABCD1234</lang> |
|||
=={{header|8086 Assembly}}== |
=={{header|8086 Assembly}}== |