ich schreibe heute drei Assemblberprogramme
global _start section .data str_src: db "hallo welt sagt David Vajda", 0 str_des: db " ", 0 str_len: dw 0 section .text _start: mov esi, str_src mov ecx, 0 loop1: lodsb cmp al, 0 je loop1end inc ecx jmp loop1 loop1end: mov [str_len], ecx mov esi, str_src mov edi, str_des strcpy: cmp ecx, 0 jle strcpyend lodsb stosb dec ecx jmp strcpy strcpyend: mov edx, [str_len] mov ecx, str_des mov ebx, 1 mov eax, 4 int 0x80 mov ebx, 0 mov eax, 1 int 80h
Und mit
rep
global _start section .data str_src: db "hallo welt sagt David Vajda", 0 str_des: db " ", 0 str_len: dw 0 section .text _start: mov esi, str_src mov ecx, 0 loop1: lodsb cmp al, 0 je loop1end inc ecx jmp loop1 loop1end: mov [str_len], ecx 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 80houtput:
david@work:~$ nasm -f elf32 nasm20241020_002.asm david@work:~$ ld -m elf_i386 nasm20241020_001.o -o nasm20241020_001 david@work:~$ ./nasm20241020_001 hallo welt sagt David Vajdadavid@work:~$ david@work:~$ david@work:~$ nasm -f elf32 nasm20241020_002.asm david@work:~$ ld -m elf_i386 nasm20241020_002.o -o nasm20241020_002 david@work:~$ ./nasm20241020_002 hallo welt sagt David Vajdadavid@work:~$ david@work:~$ david@work:~$