Copy a string: Difference between revisions
Content added Content deleted
m (→UASM 2.52) |
Puppydrum64 (talk | contribs) No edit summary |
||
Line 39: | Line 39: | ||
B DS CL64 b |
B DS CL64 b |
||
REFA DS A @a</lang> |
REFA DS A @a</lang> |
||
=={{header|68000 Assembly}}== |
|||
Making a reference to an existing string is simple. Just load its memory location into an address register. |
|||
<lang 68000devpac>myString: DC.B "HELLO WORLD",0 |
|||
EVEN |
|||
LEA myString,A3</lang> |
|||
Copying a string involves a little more work: |
|||
<lang 68000devpac>StringRam equ $100000 |
|||
myString: DC.B "HELLO WORLD",0 |
|||
EVEN |
|||
LEA myString,A3 |
|||
LEA StringRam,A4 |
|||
CopyString: |
|||
MOVE.B (A3)+,D0 |
|||
MOVE.B D0,(A4)+ ;we could have skipped D0 but this makes it easier to check for the terminator. |
|||
BEQ Terminated |
|||
BRA CopyString |
|||
Terminated: ;the null terminator is already stored along with the string itself, so we are done. |
|||
rts</lang> |
|||
=={{header|AArch64 Assembly}}== |
=={{header|AArch64 Assembly}}== |