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

مساعدة في الاسمبلي ..؟!

مغلق
بدأه بنت أكابر في 21 أكتوبر 2005 · 3 رد · 494 مشاهدة · في لغة Assembly لأنظمة 16, 32, 64 بت
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمه الله وبركاته

رمضان كريم :lol:

هذا اول موضوع لي واطلب منكم مساعده في حل هذا البرنامج

واكون لكم شاكره :rolleyes:

write a complete asembly program that defines a memory area named from length of 16 words with any contents and then performs the following tasks

move the contents of area FROM to a new area

DEST 88 immediately following area FROM

move the contents of area FROM to a new area DEST 99 immediately following area DEST88 in REVERSE order

compute the sum of the first 6 words in area DEST 99 and store it in new location FST_SUM

compute the sum of the last 6 words in area DEST 99 and store it in new location SND_SUM

store the difference between FST_SUM and snd_sum in a new location DIFF

ال 16 words يجب ان تكون اعداد الفرق بينهم 5 (5،10،15,20،25،30،35،40،................,80)

لكم تحياتي

تم تعديل هذه المشاركة بواسطة بنت أكابر في 21 أكتوبر 2005 في 13:06

#2
اقتباس
a) يمنع طلب كود لبرنامج بكامله في حال كون الغرض من البرنامج الاستخدام في اغراض تجارية "في حال لم تكن مشتركا بنظام النقاط البنكي".

B) يمنع طلب كود لبرنامج بكامله في حال كون الغرض هو حل وظيفة مقرر تدرسه "في حال لم تكن مشتركا بنظام النقاط البنكي".

تم تعديل هذه المشاركة بواسطة Xacker في 21 أكتوبر 2005 في 15:58

Do as I say, not as I do

We are Anonymous. We are Legion. We don't forgive. We don't forget

#3

لقد حاولت وقمت بكتابة هذا الكود فهل هو صحيح <_<

 
	Include Irvine32.inc 

	.data
	FRM  word	1h,2h,3h,4h,5h,6h,7h,8h,9h,10h,11h,12h,13h,14h,15h	
	DT88  word	15 dup(?); copy of FRM    
	DT99  word	15 dup(?); Reverse of DT88
	FST_SUM	word	?	; The sum of the first 6 words in area DT99
	SND_SUM	word	?	; The sum of the last 6 words in area DT99
	DIFF  word	?	; Difference between FST_SUM and SND_SUM


	.code
main    proc

	mov  esi,0 	 ; index register	
	mov  ecx,15 	 ; Loop counter
L1:	mov  eax,FRM[esi]  ; get word from FRM
	mov  DT88[esi],eax  ; store it in DT88
	INC  esi 	 ; move to the next word
	INC  esi
;add	esi,2
	Loop L1    ; Repeat 

	mov  esi,15 	 ; index register	
	mov  ecx,15 	 ; Loop counter
L2:	mov  eax,FRM[esi]  ; get word from FRM
	mov  DT99[esi],eax  ; store it in DT99
	DEC  esi 	 ; move to the next word
	DEC  esi
; sub	esi,2
	Loop L2    ; Repeat 

	mov  esi,0 	 ; index register	
	mov  ecx,6 	 ; Loop counter
	mov  eax,0 	 ; set register to 0
L3:	add  eax,DT99[esi]  ; add the first 6 word from DT99 to eax
	mov  FST_SUM[esi],eax  ; store it in FST_SUM
	INC  esi 	 ; move to the next word
	INC  esi
;add	esi,2
	Loop L3    ; Repeat 


	mov  esi,0 	 ; index register	
	mov  ecx,6 	 ; Loop counter
	mov  eax,0 	 ; set register to 0
L4:	add  eax,DT99[esi]  ; add the last 6 word from DT99 to eax
	mov  SND_SUM[esi],eax  ; store it in SND_SUM
	DEC  esi 	 ; move to the next word
	DEC  esi
; sub	esi,2
	Loop L4    ; Repeat 



	mov  eax,0 	 ; set register to 0
	mov  eax,SND_SUM
	sub  eax,FST_SUM
	mov  DIFF,eax  ; store the difference it in DIFF


main	endp
	end  main
#4

<style type='text/css'>

.terminal {

background-color: #4f5864;

border: 1px solid #394049;

margin-top: 1px;

}

.terminal#head {

background-color: #4f5964;

color: #6a7786;

padding-top: 3px;

padding-right: 10px;

padding-bottom: 3px;

padding-left: 10px;

direction: ltr;

}

pre {

font-family: courier new, courier, verdana, arial;

font-weight: normal;

font-size: 13px;

color: #aeaeae;

background-color: #56606d;

padding-top: 3px;

padding-right: 10px;

padding-bottom: 3px;

padding-left: 10px;

direction: ltr;

}

h2 {

font-family: verdana, tahoma, arial;

font-size: 100%;

color: #ffffff;

background-image: url(http://www.arabteam2000.com/picload/pics/21_10_05_07_28_59_1129948139box.gif);

background-repeat: no-repeat;

background-position: left;

padding-left: 18px;

margin: 0px;

}

</style>

رمضان كريم واعاده الله علينا وعليك اختي الكريمة..

في البداية، لا يوجد داع للوجوه الممتعضة :) فالغرض الاول والاخير من تحديد هذه القواعد للمشاركة في القسم هو امران، اولهما هو الحول دون تحويل القسم الى منطقة free zone لحل الواجبات والوظائف، اما الغاية الثانية فهي تصب في صالح العضو الذي يسال فهو لو حاول واخطا افضل بالف مرة من ان يتكل على غيره في الحل والذي لن يفهم او لن يستطيع ان يدرك ابعاده كما لو كتبه بنفسه.. لو انك طرحت مشاركتك في البداية لوجدت الجواب فورا ولكن استفسارك بدا كغيره من طلبات حل الوظائف التي لا تنتهي والتي لا نقبل بها في القسم.. باي حال لا اريد ان اطيل عليك.. ما كتبته شبه صحيح لكنك غفلت عن عدة امور وهناك استخدامات اسهل لبعض النقاط الاخرى..

هاك تعديلي على ما كتبت وهو مكتوب في masm32:

<table border=0 align='center' width=100% height=100% valign='middle'>

<tr>

<td valign='middle' align='center'>

<table align='center' width=100% cellspacing=1 cellpadding=0 class='terminal'>

<tr>

<td align='left' class='terminal' id='head' colspan=1><h2><blink>CODE</blink></h2>

</td>

</tr>

<tr>

<td align='left'>

<pre>

;=====================================

; copyright 2005 © ArabTeam2000

;=====================================

.386

.model flat,stdcall

option casemap:none

.data

FRM dw 1h,2h,3h,4h,5h,6h,7h,8h,9h,10h,11h,12h,13h,14h,15h

DT88 dw 15 dup(?)

DT99 dw 15 dup(?)

FST_SUM dd ? ; DWORDs because if the WORDs were something like FFFF, FFFA, .... then the sum is a DWORD

SND_SUM dd ?

DIFF dd ?

.code

;========================

main proc near

;---

;move the contents of area FROM to a new area DEST 88 immediately following area FROM

;---

lea esi, FRM ; load addr of FRM to ESI

lea edi, DT88 ; load = of DT88 to EDI

xor ecx, ecx ; empty ECX

L1:

cmp cx, 30 ; finished looping?

; '30' is because we loop into 15 words by 2bytes per loop

jae xL1 ; pass if finished looping

mov ax, word ptr [esi+ecx] ; copy $th word from ESI to AX

imul ax, 5 ; make difference by 5 :o]

mov word ptr [edi+ecx], ax ; copy AX contents to EDI

add cx, 2 ; increment CX by 2 to take next WORD

jmp L1 ; and loop

xL1:

;---

;move the contents of area FROM to a new area DEST 99 immediately following area DEST88 in REVERSE order

;---

;lea esi, FRM ; << not required, ESI still holds the addr

lea edi, DT99 ; load addr of DT99 to EDI

sub ecx, 2 ; we use the same counter with reversed order :o]

xor ebx, ebx ; counter for storing in foreward order

L2:

cmp bx, 30 ; finished looping?

jae xL2 ; do what you have to do!

mov ax, word ptr [esi+ecx] ; get last word from ESI and store it in AX

imul ax, 5 ; again multiply it by 5

mov word ptr [edi+ebx], ax ; and copy it to EDI (reversed order)

sub cx, 2 ; decrement CX by 2 to take previous WORD

add bx, 2 ; increment by 2 to store in next WORD

jmp L2 ; do loop

xL2:

;---

;compute the sum of the first 6 words in area DEST 99 and store it in new location FST_SUM

;---

;lea edi, DT99 ; << not required

xor ecx, ecx

L3:

cmp cx, 12 ; finished looping?

jae xL3 ; go exit

mov ax, word ptr [edi+ecx] ; read the WORD and store it in AX

add dword ptr [FST_SUM], eax ; now add it to the sum of the WORDs

add cx, 2 ; get next WORD

jmp L3 ; loop

xL3:

;---

;compute the sum of the last 6 words in area DEST 99 and store it in new location SND_SUM

;---

;lea edi, DT99 ; << not required

mov ecx, 28 ; '28' to get the last WORD

L4:

cmp cx, 28-12 ; '28-12' to count only 6 WORDS (12bytes)

jbe xL4 ; and exit when matchs

mov ax, word ptr [edi+ecx] ; copy WORDs from DST99 backwarded to AX

add dword ptr [sND_SUM], eax ; and calculate the sum in SND_SUM

sub cx, 2 ; back to previous WORD

jmp L4 ; loop

xL4:

;---

;store the difference between FST_SUM and SND_SUM in a new location DIFF

;---

mov eax, dword ptr [FST_SUM] ; put value of FST_SUM in EAX

sub eax, dword ptr [sND_SUM] ; and decrease it by the value of SND_SUM

mov dword ptr [DIFF], eax ; then store results in DIFF

;---

;return safely to DOS

;---

ret ; pop 1st DWORD in stack (0000-PSP) -> return to DOS

;---

main endp

;========================

end main

</pre>

</td>

</tr>

</table>

</td>

</tr>

</table>

الان راجعي الاختلافات وقد عملت على وضع تعليق لكل سطر كي لا يكون هناك اي شئ غامض عن اي شخص قد يود استخلاص الكود والتعديل عليه حسب حاجته..

بالتوفيق ونتمنى رؤيتك في القسم مرة اخرى (بدون واجبات ;) )

simple factorial.zip

تم تعديل هذه المشاركة بواسطة Xacker في 22 أكتوبر 2005 في 05:29

Do as I say, not as I do

We are Anonymous. We are Legion. We don't forgive. We don't forget

هذا الموضوع مغلق.

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