# Langage assemblage

**URL:** <https://www.debian-fr.org/t/langage-assemblage/77152>\
**Category:** Programmation\
**Tags:** assembleur\
**Created:** [Juillet 7, 2018, 1:31 UTC](https://www.debian-fr.org/t/langage-assemblage/77152 "2018-07-07T13:31:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LAMY231](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/l/b38774/32.png) [@LAMY231](https://www.debian-fr.org/u/LAMY231)\
**Post date:** [Juillet 7, 2018, 1:31 UTC](https://www.debian-fr.org/t/langage-assemblage/77152/1 "2018-07-07T13:31:45Z")

</div>

Bonjour,

j’ai fait de la programmation autrefois, là il s’agit d’un petit essai en assembleur pour me familiariser avec ce langage d’assemblage ce qui me permettrait d’en inclure dans du C, mais ça ne fonctionne pas. Je serais très désireux de bénéficier d’un éclairage pour comprendre ce qui ne va pas.

Je suis sous Debian Gnu/Linux 7.11 (wheezy).  
Le processeur est un AMD Athlon™ II x2 250.  
CPU 3 Ghz. Cache size:1024 KB. Adress sizes : 48 bits. Cl flush size : 64. CPU famille : 16.

J’ai d’abord installé nasm. Puis j’ai créé un petit fichier avec gedit, nommé : essai.asm :

```nohighlight
1. .data 
2. msg :	.asciz "Hello, world !\n" 
3. len = . - msg 
4. .bss 
5. .text 
6. .global _start 
7. 
8. _start : 
9. movl $msg,%ecx 
10. movl $len,%edx 
11. movl $1,%ebx 
12. movl $4,eax 
13. int $0x80 # appel system 
14. 
15. exit : 
16. movl $0,%ebx 
17. movl $1,%eax 
18. int $0x80

```

Le problème commence quand je passe à l’assemblage. J’applique la commande suivante :  
nasm -f elf essai.asm J’obtiens : unable to open input file essai.asm.

Si vous remarquez où est le problème je serais très heureux que vous m’en fassiez part.  
Avec mes remerciements anticipés et mes cordiales salutations.

J-C L

---

<div class="post-metadata">

**Author:** ![jb12](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@jb12](https://www.debian-fr.org/u/jb12)\
**Post date:** [Juillet 7, 2018, 3:36 UTC](https://www.debian-fr.org/t/langage-assemblage/77152/2 "2018-07-07T15:36:33Z")

</div>

[http://asm.sourceforge.net/intro/hello.html](http://asm.sourceforge.net/intro/hello.html)

---

<div class="post-metadata">

**Author:** ![Almtesh](https://www.debian-fr.org/user_avatar/www.debian-fr.org/almtesh/32/10312_2.png) [@Almtesh](https://www.debian-fr.org/u/Almtesh)\
**Post date:** [Juillet 9, 2018, 9:29 UTC](https://www.debian-fr.org/t/langage-assemblage/77152/3 "2018-07-09T09:29:55Z")

</div>

> [@LAMY231](#):
>
> J’applique la commande suivante :
> 
> nasm -f elf essai.asm J’obtiens : unable to open input file essai.asm.

Peut-être faut-il faire `nasm -f elf ./essai.asm` à la place…  
Sinon, vérifie que tu es dans le bon dossier et regarde si tu vois bien ton fichier (`ls -l ./essai.asm`) et si ton utilisateur peut bien le lire (`cat ./essai.asm`).

> [@jb12](#):
>
> [http://asm.sourceforge.net/intro/hello.html](http://asm.sourceforge.net/intro/hello.html)

Et paf ! Lis la doc !

---

<div class="post-metadata">

**Author:** ![LAMY231](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/l/b38774/32.png) [@LAMY231](https://www.debian-fr.org/u/LAMY231)\
**Post date:** [Juillet 9, 2018, 10:19 UTC](https://www.debian-fr.org/t/langage-assemblage/77152/4 "2018-07-09T10:19:23Z")

</div>

J’avais lu les infos sur les différents sites internet mais il me manquait la petite lumière  
qui permet d’atteindre le but. Avec persévérance c’est chose faite.  
Merci pour les infos et surtout pour le " Et paf ! Lis la doc !"

---

<div class="post-metadata">

**Author:** ![Almtesh](https://www.debian-fr.org/user_avatar/www.debian-fr.org/almtesh/32/10312_2.png) [@Almtesh](https://www.debian-fr.org/u/Almtesh)\
**Post date:** [Juillet 9, 2018, 10:32 UTC](https://www.debian-fr.org/t/langage-assemblage/77152/5 "2018-07-09T10:32:33Z")

</div>

Si le problème est résolu, merci de nous préciser comment et de marquer le sujet comme résolu en cliquant sur la coche dans le message contenant la solution, y compris s’il s’agit de ton propre message.

---

<div class="post-metadata">

**Author:** ![jb12](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@jb12](https://www.debian-fr.org/u/jb12)\
**Post date:** [Juillet 9, 2018, 3:12 UTC](https://www.debian-fr.org/t/langage-assemblage/77152/6 "2018-07-09T15:12:48Z")

</div>

dans les 2 syntaxes d’ assemblage:

```auto
root@alpha30:/home/jb1# nasm -f elf64 es1.asm
root@alpha30:/home/jb1# ld -s -o es1 es1.o 
root@alpha30:/home/jb1# ./es1
Hello, world!
root@alpha30:/home/jb1# 
```

---

<div class="post-metadata">

**Author:** ![LAMY231](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/l/b38774/32.png) [@LAMY231](https://www.debian-fr.org/u/LAMY231)\
**Post date:** [Juillet 9, 2018, 5:22 UTC](https://www.debian-fr.org/t/langage-assemblage/77152/7 "2018-07-09T17:22:46Z")

</div>

J’avais 2 fichiers .asm . Le premier étant essai et le second hello2, j’ai travaillé avec hello2 pour écrire “Hello World !” . La syntaxe serait la même avec mon premier fichier: essai. Voilà ce qui a bien fonctionné:  
/Documents/Linux$ nasm -f elf64 hello2.asm -o hello2.o  
/Documents/Linux$ ld -o hello2 hello2.o  
hello2: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped  
/Documents/Linux$ ./hello2  
Hello world!  
Ci-dessous mon fichier hello2.asm:

bits 64  
global \_start

section .data  
Hello db “Hello world!”, 10

section .text  
\_start:  
mov rax, 1 ; sys\_write  
mov rdi, 1 ; stdout  
mov rsi, Hello  
mov rdx, 13  
syscall

```
mov rax, 60 ; sys_exit
xor rdi, rdi ; exit(0)
syscall

```

Mes excuses pour l’envoi précédent le message est parti inopinément alors que je tapais le texte.

---

<div class="post-metadata">

**Author:** ![LAMY231](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/l/b38774/32.png) [@LAMY231](https://www.debian-fr.org/u/LAMY231)\
**Post date:** [Juillet 9, 2018, 5:44 UTC](https://www.debian-fr.org/t/langage-assemblage/77152/8 "2018-07-09T17:44:51Z")

</div>

J’avais 2 fichiers .asm . Le premier étant essai et le second hello2, j’ai travaillé avec hello2 pour écrire “Hello World !” . La syntaxe serait la même avec mon premier fichier: essai. Voilà ce qui a bien fonctionné:  
/Documents/Linux$ nasm -f elf64 hello2.asm -o hello2.o  
/Documents/Linux$ ld -o hello2 hello2.o  
hello2: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped  
/Documents/Linux$ ./hello2  
Hello world!  
Ci-dessous mon fichier hello2.asm:

bits 64  
global \_start

section .data  
Hello db “Hello world!”, 10

section .text  
\_start:  
mov rax, 1 ; sys\_write  
mov rdi, 1 ; stdout  
mov rsi, Hello  
mov rdx, 13  
syscall

```
mov rax, 60 ; sys_exit
xor rdi, rdi ; exit(0)
syscall

```

Mes excuses pour l’envoi précédent le message est parti inopinément alors que je tapais le texte.

---

<div class="post-metadata">

**Author:** ![LAMY231](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/l/b38774/32.png) [@LAMY231](https://www.debian-fr.org/u/LAMY231)\
**Post date:** [Juillet 9, 2018, 5:50 UTC](https://www.debian-fr.org/t/langage-assemblage/77152/9 "2018-07-09T17:50:32Z")

</div>

Ne pas tenir compte de ce qui c’est rajouté et qui n’a rien à voir avec mon message: mov rax, 60 ; sys\_exit … jusqu’à syscall.

C’est la première fois que j’utilise cette messagerie; je dois bénéficier de circonstances atténuantes.  
Merci.

---

<div class="post-metadata">

**Author:** ![jb12](https://www.debian-fr.org/letter_avatar_proxy/v4/letter/j/48db29/32.png) [@jb12](https://www.debian-fr.org/u/jb12)\
**Post date:** [Juillet 9, 2018, 7:31 UTC](https://www.debian-fr.org/t/langage-assemblage/77152/10 "2018-07-09T19:31:50Z")

</div>

bonsoir,  
prochaine étape, debug de son exécutable,  
puis manipulation de fichiers,  
j’arréte de répondre, le sujet est clos  
bonne soirée
