;; (c) David Vajda
;; netwide Assembler - i386/i586/amd64 - sort elements in string
;; 2025-07-04
global _start
section .stack
;;_stack: dq 0, 0, 0, 0, 0, 0, 0, 0
section .data
toSortString: db "hallo_ich.werde-versuchen_diesen..string^^hier...zu_sortieren", 10, 13, 0x00
section .text
_start:
mov edi, toSortString
loop1:
mov eax, 10
cmp [edi], eax
je loop1end
mov esi, edi
loop2:
inc esi
mov eax, 10
cmp [esi], eax
je loop2end
mov eax, [esi]
mov ebx, [edi]
cmp eax, ebx
jle noexchange
mov eax, [esi]
mov ebx, [edi]
mov [esi], ebx
mov [edi], eax
noexchange:
jmp loop2
loop2end:
inc edi
jmp loop1
loop1end:
mov edi, toSortString
;;mov edx, 0x00
loop3:
mov eax, 10
cmp eax, [edi]
je loop3end
inc edi
inc edx
loop3end:
push edx
;;pop edx
mov edx, 61
mov ecx, toSortString
mov eax, 0x04
mov ebx, 0x01
int 0x80
mov eax, 0x01
mov ebx, 0x00
int 0x80