السلام عليكم ورحمة الله وبركاته
بدأت أمس\قبل أمس بتعلم الأسمبلي .. قرأت هنا وهناك حتى وجدت موضع قدم . كتبت عدد من الأكواد البسيطة. وهذا آخر ماوصلت له
حاولت أعمل حلقة تكرار loop ودائما تفشل ( أعلم أن هناك if و while في masm ولكنني إريد أن أتعلم الأسمبلي الكلاسيكسة ) :
.486 .model flat, stdcall option casemap :none include \masm32\include\kernel32.inc include \masm32\include\user32.inc include \masm32\include\masm32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\masm32.lib .data text db "Hi, this is a loop!",13,10,0 .code start: xor eax,eax loopprint: push offset text call StdOut inc eax end loopprint call loopprint cmp eax,10 jnz loopprint push offset text call StdOut push 0 call ExitProcess end start
قام بعملية الطباعة مرّة واحدة فقط .. في المحاولة الثانية :
.486 .model flat, stdcall option casemap :none include \masm32\include\kernel32.inc include \masm32\include\user32.inc include \masm32\include\masm32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\masm32.lib .data text db "Hi, this is a loop!",13,10,0 .code start: xor eax,eax push eax call code1 code1: push offset text call StdOut pop eax inc eax push eax call code2 end code1 code2: pop eax cmp eax, 10 jnz code1 end code2 push 0 call ExitProcess end start
ظهر لي خطأ :
loop.asm(34) : error A2006: undefined symbol : code2
حاولت تجاوزة بهذا الكود :
.486 .model flat, stdcall option casemap :none include \masm32\include\kernel32.inc include \masm32\include\user32.inc include \masm32\include\masm32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\masm32.lib .data text db "Hi, this is a loop!",13,10,0 .code start: xor eax,eax push eax call code1 code1: push offset text call StdOut pop eax inc eax push eax xor ebx,ebx mov ebx, offset code2 call ebx end code1 code2: pop eax cmp eax, 10 jnz code1 end code2 push 0 call ExitProcess end start
ولم أفلح ,, وطبعا بدأت تتتحول المحاولات للنوع الغبي :lol: , ما المشكلة فيه ؟
وسؤال آخر .. كيف أنقل قيمة إلى عنوان في الذاكرة ؟ محاولتي قمت بإنشاء متغير :
adder db ?
وحاولت أن أنقله له قيمه هكذا :
mov offset adder, "ABCD"
و
mov offset adder, 1
ولكن يبدو أنني إرتكبت خطأ فظيع :blush::P