|
Revision 9, 1.1 kB
(checked in by haypo, 1 year ago)
|
Add hello.s
|
- Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 |
/* |
|---|
| 2 |
* Hello WORLD en assembleur pour Linux en utilisant les appels |
|---|
| 3 |
* systemes (int 0x80). Ce code est destine aux processeurs compatibles |
|---|
| 4 |
* Intel x86. Il a testé avec un noyau 2.4.21 sur PentiumIV 1.4 GHz. |
|---|
| 5 |
* |
|---|
| 6 |
* A compiler avec : |
|---|
| 7 |
* o as hello.s -o hello.o |
|---|
| 8 |
* o ld -s hello.o -o hello |
|---|
| 9 |
* (-s pour enlever les symboles de debogage) |
|---|
| 10 |
* |
|---|
| 11 |
* Victor STINNER - 29 septembre 2003 |
|---|
| 12 |
* http://www.haypocalc.com/ |
|---|
| 13 |
*/ |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
.data |
|---|
| 17 |
#----------------------------------------------------------------------------- |
|---|
| 18 |
# Appels systeme |
|---|
| 19 |
SYS_exit = 1 |
|---|
| 20 |
SYS_write = 4 |
|---|
| 21 |
|
|---|
| 22 |
# E/S standards |
|---|
| 23 |
STDOUT=1 |
|---|
| 24 |
|
|---|
| 25 |
# Chaine de caractere |
|---|
| 26 |
txt: .string "Hello World !\n" # chaine d'exemple |
|---|
| 27 |
lgtxt = . - txt # longueur de la chaine, . = adresse courant |
|---|
| 28 |
|
|---|
| 29 |
.text |
|---|
| 30 |
#----------------------------------------------------------------------------- |
|---|
| 31 |
.global _start |
|---|
| 32 |
_start: |
|---|
| 33 |
mov $SYS_write,%eax # fonction WRITE |
|---|
| 34 |
mov $STDOUT,%ebx # fichier |
|---|
| 35 |
mov $txt,%ecx # adresse de la chaine |
|---|
| 36 |
mov $lgtxt,%edx # longueur du texte |
|---|
| 37 |
int $0x80 |
|---|
| 38 |
|
|---|
| 39 |
mov $SYS_exit, %eax # fonction EXIT |
|---|
| 40 |
mov $0,%ebx # code se sortie |
|---|
| 41 |
int $0x80 |
|---|
| 42 |
|
|---|
| 43 |
#----------------------------------------------------------------------------- |
|---|