nasm20241125001sort.asm


;; (C) David Vajda
;; i586/x86/amd64 - Sort
;; 2024-11-25

    global _start
    section .data
        ToSrtString: db "sjfmcmcnmhqwqwasdbnsadabasnd", 0x00
    section .text
_start:

    mov esi, ToSrtString
loop2:
    mov al, [esi]
    cmp al, 0x00
    je loop2end
    mov edi, esi
loop3:
    inc edi
    mov al, [edi]
    cmp al, 0x00
    je loop3end
    mov ah, [esi]
    mov al, [edi]
    cmp ah, al
    jge noexchange
    mov ah, [esi]
    mov al, [edi]
    mov [edi], ah
    mov [esi], al
noexchange:
    jmp loop3
loop3end:
    inc esi
    jmp loop2
loop2end:

    mov esi, ToSrtString
    mov ecx, 0
loop1:
    mov al, [esi]
    cmp al, 0
    je loop1end
    inc ecx
    inc esi
    jmp loop1
loop1end:

    mov edx, ecx
    mov ecx, ToSrtString
    mov eax, 4
    mov ebx, 1
    int 0x80

    mov eax, 1
    mov ebx, 0
    int 0x80

Ausgabe


david@work:~$ nasm -f elf32 nasm20241125001sort.asm
david@work:~$  ld -m elf_i386 nasm20241125001sort.o -o nasm20241125001sort
david@work:~$ ./nasm20241125001sort
wwssssqqnnnmmmjhfdddccbbaaaadavid@work:~$