1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| section .text
global _start
_start:
mov eax, 3
mov ebx, 0
mov ecx, msg
mov edx, 10 ; longueur
int 0x80 ; stdin
mov eax, 10
cherche_fin:
dec eax
lea esi, [msg+eax]
cmp BYTE [esi], 0
jz cherche_fin ;après ce passage esi pointe sur le dernier caractère (car msg est dans bss)
add eax, 1
mov edx, eax ;on sauvegarde la taille dans edx
mov ebp, esp
sub esp, eax
mov edi, esp ;réservation de len octets sur la pile
boucle:
mov bl, [esi]
mov [edi], bl
inc edi
dec esi
dec eax
cmp eax, 0
jnz boucle
mov eax, 4
mov ebx, 1
mov ecx, esp
int 80h ;stdout msg, edx est déja initialisé
mov eax, 1
mov ebx, 0
int 80h ;quit
section .bss
msg resb 10 |
Partager