assembly se linux

Alejandros Diamandidis adia at egnatia.ee.auth.gr
Thu Apr 29 13:20:07 EEST 1999


abas at aix.meng.auth.gr (Bassoukos Tassos) wrote:
>> Eno programatiza se assembly se dos, eipa na to giriso
>> se linux.
>
...
>initialization functions. Epishs, ean 8es na kaneis otidhpote pio
>polyploko apo to na epistrefeis, 8a xreiasteis ton /lib/ld-linux.so
>(dynamic loader) kai isws kai kapoia libc.so (ean 8es c-functions, alla
>meta 8a blexeis me ta calling conventions).

Ayto den einai teleiws alhtheia - an theleis, mporeis na mh
xrhsimopoihseis kamia bibliothiki (oute kan to crt1.o!). Oriste
ena "hello world" se assembly:

---8<-----hello.s--------------------------------
.section        .text
.global _start
_start:
        movl    $4, %eax
        movl    $1, %ebx
        movl    $hello, %ecx
        movl    $14, %edx
        int     $0x80
        movl    $1, %eax
        movl    $0, %ebx
        int     $0x80
hello:
        .ascii  "Hello, world!\n"
---8<--------------------------------------------

To kaneis assemble kai link me tis parakatw entoles:

as -o hello.o hello.s
ld -s -o hello hello.o

Sto systhma mou, to `hello' bgainei 408 byte.

H klhsh twn system calls ginetai bazontas ston %eax ton arithmo
ths klhshs, kai tis parametrous stous %ebx, %ecx, %edx kok.
(de thymamai pou pane oi alles parametroi, an xreiazontai),
kai meta dinontas `int $0x80'. Gia perissoteres plhrofories
mporeis na diabaseis ton kwdika ths libc kai tou pyrhna (egw
pantws den to exw kanei ;) Oi arithmoi twn syscalls kai o tropos
klhshs tous briskontai sto /usr/src/linux/include/asm-i386/unistd.h

>  Proswpika protimw na grafw ton perissotero kwdika se C kai mono ta
>kommatia pou exei nohma na grafoun se assembly ta kanw me to xeri.

Ayto mallon einai h kalyterh lysh, an endiaferesai na kaneis kapoia
douleia kai oxi mono na graceis se assembly gia thn plaka tou thematos!

-- 
Alejandros Diamandidis * adia at egnatia.ee.auth.gr
--
====================================================================
Gia boithia (h na diagrafhte) e-mail sto majordomo at hellug.gr
Ta archives tis listas einai sto http://lists.hellug.gr/archives
prin steilete kapoia erothsh psakte mipos exei hdh apanththei.
Gia opoiodipote problima stilte e-mail ston owner-linux-greek-users at hellug.gr
====================================================================



More information about the Linux-greek-users mailing list