nasm20241130001sort.asm

;; (C) David Vajda
;; 2024-11-30
;; sort - nasm i586/i386/amd64

global _start

section .data
        ToSortString: db "HaisdanmgoqweqSADASDncyxcyxdksks", 10, 13
section .text
_start:
mov esi, ToSortString
Loop2:
mov ah, [esi]
cmp ah, 10
je Loop2end
mov edi, esi
Loop3:
inc edi
mov al, [edi]
cmp al, 10
je Loop3end
mov ah, [esi]
mov al, [edi]
cmp al, ah
jge NoExchange
mov ah, [esi]
mov al, [edi]
mov [esi], al
mov [edi], ah
NoExchange:
jmp Loop3
Loop3end:
inc esi
jmp Loop2
Loop2end:


mov esi, ToSortString
mov ecx, 0x00
Loop1:
mov al, [esi]
cmp al, 10
je Loop1end
inc ecx
inc esi
jmp Loop1

add ecx, 2
Loop1end:
mov edx, ecx
mov ecx, ToSortString
mov eax, 0x04
mov ebx, 0x01
int 0x80
mov eax, 0x01
mov ebx, 0x00
int 0x80