
02-06-2009, 02:44
|
|
|
|
חבר מתאריך: 02.06.09
הודעות: 4
|
|
|
ייעול תוכנית באסמבלי
אנשים טובים,
יש לי משימת בונוס לייעל תוכנית שרשומה באלסמבלי.
אני קצת "ירוק" באסמבלי (בגלל זה המשימה היא בונוס)
אשמח לכל עזרה שהיא... אפילו קטנה...
לילה טוב
input: array starting at address 400 containing 100 digits (binary).
output: in address 800 calculate the result of the pairty function - writes 0 if the number of "1" is evne, else writes 1.
0 la,400
4 ld r3,0(r1)
8 la r9,0
12 andi r5,r3,1
16 lar 76,8
20 r6,r5
24 sddi r7, r7,1
28 shr r3, r3,1
32 lar r8,-24
36 brnz r8,r7
40 andi r7,r7,1
44 la r5,0
48 lar r10,8
52 brzr r10,8
56 not r5,r5
60 st 400(r1)
64 addi r1,r1,4
68 addi r9,r1,-800
72 brnz r10,r9
76 stop
modify the program and make it as eficient as you can.
|