2024-10-22, Assembler-Programm

global  _start
        segment     .data
        str_src:    db  "hallo, ich bin die Quelle", 0
        str_des:    db  "hallo, ich bin das Ziel  ", 0
        str_len:    dw 0x00
        segment     .text
_start:
        mov esi, str_des
        mov ecx, 0
loop1:
        lodsb
        cmp al, 0x00
        je loop1end
        inc ecx
        jmp loop1
loop1end:

        mov [str_len], ecx

        mov edx, [str_len]
        mov ecx, str_des
        mov ebx, 1
        mov eax, 4
        int 0x80

        mov ecx, [str_len]
        mov esi, str_src
        mov edi, str_des
        rep movsb


        mov edx, [str_len]
        mov ecx, str_des
        mov ebx, 1
        mov eax, 4
        int 0x80

        mov ebx, 0
        mov eax, 1
        int 80h

bash:

david@work:~$ nasm -f elf32 nasm20241021.asm
david@work:~$  ld -m elf_i386 nasm20241021.o -o nasm20241021
david@work:~$ ./nasm20241021
hallo, ich bin das Ziel  hallo, ich bin die Quelledavid@work:~$