الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

محتاج أسمبلر ل لنكس ...

بدأه hamany-pirlo في 22 ديسمبر 2009 · 7 رد · 918 مشاهدة · في نظام تشغيل Unix & Linux
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

ممكن أعرف كيف أعمل compile for assembly code in linux ؟

Program every day for 20 years and you will become a good programmer. Program every day for 10 years and study algorithms on the side and you will become a great programmer !

على الأقل هذا اللي سمعته ...

#2

NASM

FASM

و أفضل الأول

forum-signature-01.gif
#3
sudo apt-get install nasm
amdvsintel22.jpg

--i use AMD--

لا اله الا الله محمد رسول الله

أستعن بالله و لا تعجز

تابعنى على تويتر

***

#4

سويت install for nasm ، بس كيف أعمل compile لأسمبلي كود ؟

مثلا لو عندي ملف hello.s ، كيف يكون ال command in the terminal ؟

تم تعديل هذه المشاركة بواسطة hamany-pirlo في 22 ديسمبر 2009 في 22:01

Program every day for 20 years and you will become a good programmer. Program every day for 10 years and study algorithms on the side and you will become a great programmer !

على الأقل هذا اللي سمعته ...

#5
nasm -f elf hello.s -o hello

run

./hello

تم تعديل هذه المشاركة بواسطة SudaNix في 23 ديسمبر 2009 في 03:20

#6

عملت الذي قال عليه الأخ SudaNix ، و طلع معاي errors كثير ؟

و لكن عندما عملت gcc hello.s و من ثم run for hello.s

طلعلي error واحد و اللي هو bad register name %ebp ؟

و هذا السي كود

int foo(int *a, int b);

main()
{
    int m,n;

    m=5;
    n=7;

    foo(&n, m);

    }


int foo(int *a, int b)
{
    int w=4*b;

    *a=*a+b;

    return *a;

    }

و هذا الأسمبلي كود

main:

pushl	 %ebp
movl	 %esp, %epb
subl	$8, %esp
movl	$5, -4(%ebp) 
movl	$7, -8(%ebp)
pushl	-4(%ebp)
leal	-8(%ebp),%edx		# %edx=&n
pushl	%edx
call	foo
movl	%ebp, %esp
popl	%ebp
ret


foo:

pushl	%ebp
movl	%esp, %ebp
subl	$4, %esp
movl	(%edx),%eax		# %eax=*a
movl	12(%ebp), %ecx
sall	$2, %ecx
movl	%ecx, -4(%ebp)		# w=-4(%ebp)=4*b
addl	12(%ebp), %eax	# *a=*a+b
movl	%ebp, %esp
popl	%ebp
ret

ملاحظة : الأسمبلي كود مكتوب باليد وليس عن طريق الgcc كومبايلر

تم تعديل هذه المشاركة بواسطة hamany-pirlo في 23 ديسمبر 2009 في 18:32

Program every day for 20 years and you will become a good programmer. Program every day for 10 years and study algorithms on the side and you will become a great programmer !

على الأقل هذا اللي سمعته ...

#7

جرب الكود الاتى يا اخى لعله يعمل :

[BITS 32]                       ; All instructions should be 32-bit.


main:

pushl    ebp
movl     esp, epb
subl    8, esp
movl    5, -4(ebp) 
movl    7, -8(ebp)
pushl   -4(ebp)
leal    -8(ebp),edx 
pushl   edx
call    foo
movl    ebp, esp
popl    ebp
ret


foo:
pushl   ebp
movl    esp, ebp
subl    4, esp
movl    (edx),eax             
movl    12(ebp), %ecx
sall    2, ecx
movl    ecx, -4(ebp)         
addl    12(ebp), eax 
movl    ebp, esp
popl    ebp
ret
amdvsintel22.jpg

--i use AMD--

لا اله الا الله محمد رسول الله

أستعن بالله و لا تعجز

تابعنى على تويتر

***

#8

لم يعمل معي الكود يا eramax :huh:

و لكن ما عليه ، خيرها بغيرها :) ، المهم انه االكود صحيح و ال gcc يعمل check for syntax error و هذا أهم شيء ، لأن هدفي هو تعلم لغة الأسمبلي و حبيت أعمل exercises لنفسي كمكمّل للذي أدرسه بالجامعة .

و يعطيكم العافية جميعا . :happy:

Program every day for 20 years and you will become a good programmer. Program every day for 10 years and study algorithms on the side and you will become a great programmer !

على الأقل هذا اللي سمعته ...

مواضيع مشابهة