RosettaCodeData/Task/Copy-a-string/X86-Assembly/copy-a-string-2.x86

23 lines
422 B
Plaintext

section .data
string db 11,"Hello World"
section .bss
string2 resb 12
section .text
global _main
_main:
xor ecx, ecx ;clear ecx
mov cl, [string]
mov [string2], cl ;copy byte signaling length
mov edx, 1
looping: ;copy each single byte
mov al, [string + edx]
mov [string2 + edx], al
inc edx
dec ecx
cmp ecx, 0
jg looping
xor eax, eax
ret