Copy a string: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 2,700: | Line 2,700: | ||
jr StrCpy</lang> |
jr StrCpy</lang> |
||
If you're using the "Pascal style" where the string length is prepended before the string itself, you can use this method instead, assuming your string is shorter than 255 bytes in length. |
|||
<lang z80>ld hl,myString |
|||
ld c,(hl) |
|||
ld b,0 |
|||
inc c |
|||
ld de,buffer |
|||
ldir ;copies from (HL) to (DE), BC times. |
|||
ret |
|||
myString: |
|||
byte 5 ;len("Hello") |
|||
byte "Hello" |
|||
buffer: |
|||
byte 0 |
|||
byte 0,0,0,0,0</lang> |
|||
=={{header|Zig}}== |
=={{header|Zig}}== |