1 / 6

計算: Σ i

10. 計算: Σ i. i=0. move #0, GR0 //i move GR0, $i move #0, GR1 //S move GR1, $S L1: move $i, GR0 sub #10, GR0 jpgt L2 move $S, GR1 move $i, GR0 add GR0, GR1 move GR1, $S add #1, GR0 move GR0, $i jump L1 L2: halt // i: ds.1 S: ds.1 //end of program. 漸化式表現:

mira-vang
Download Presentation

計算: Σ i

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 10 計算:Σ i i=0 move #0, GR0 //i move GR0, $i move #0, GR1 //S move GR1, $S L1: move $i, GR0 sub #10, GR0 jpgt L2 move $S, GR1 move $i, GR0 add GR0, GR1 move GR1, $S add #1, GR0 move GR0, $i jump L1 L2: halt // i: ds.1 S: ds.1 //end of program 漸化式表現: S(0)=0 S(i)=S(i-1) +i i=0,..,10 変数を簡略: S=0 S=S+i i=0,..,10

  2. メモリ領域の番号 0: move #0, GR0 1: move GR0, $i 2: move #0, GR1 3: move GR1, $S //L1: 4: move $i, GR0 5: sub #10, GR0 6: jpgt L2 7: move $S, GR1 8: move $i, GR0 9: add GR0, GR1 10: move GR1, $S 11: add #1, GR0 12: move GR0, $i 13: jump L1 //L2: 14: halt // //i: 20: ds.1 //S: 21: ds.1 //end of program move #0, GR0 //i move GR0, $i move #0, GR1 //S move GR1, $S L1: move $i, GR0 sub #10, GR0 jpgt L2 move $S, GR1 move $i, GR0 add GR0, GR1 move GR1, $S add #1, GR0 move GR0, $i jump L1 L2: halt // i: ds.1 S: ds.1 //end of program

  3. 0: move #0, GR0 1: move GR0, $i 2: move #0, GR1 3: move GR1, $S //L1: 4: move $i, GR0 5: sub #10, GR0 6: jpgt L2 7: move $S, GR1 8: move $i, GR0 9: add GR0, GR1 10: move GR1, $S 11: add #1, GR0 12: move GR0, $i 13: jump L1 //L2: 14: halt // //i: 20: ds.1 //S: 21: ds.1 //end of program 0: move #0, GR0 1: move GR0, 20 //$i 2: move #0, GR1 3: move GR1, 21 //$S //L1: 4: move 20, GR0 //$i, GR0 5: sub #10, GR0 6: jpgt 14 //L2 7: move 21, GR1 //$S, GR1 8: move 20, GR0 //$i, GR0 9: add GR0, GR1 10: move GR1, 21 //$S 11: add #1, GR0 12: move GR0, 20 //$i 13: jump 4 //L1 //L2: 14: halt // //i: 20: ds.1 //S: 21: ds.1 //end of program address resolution L1 -> 4 L2 -> 14 i -> 20 S -> 21

  4. move #0, GR0 //i move GR0, $i move #0, GR1 //S move GR1, $S L1: move $i, GR0 sub #10, GR0 jpgt L2 move $S, GR1 move $i, GR0 add $A(GR0), GR1 move GR1, $S add #1, GR0 move GR0, $i jump L1 L2: halt // i: ds.1 S: ds.1 A: ここからデータが並ぶ 10 計算:Σa(i) i=0 配列 漸化式表現: S(0)=0 S(i)=S(i-1) +a(i) i=0,..,10 違いはここだけ! 変数を簡略: S=0 S=S+a(i) i=0,..,10

  5. move #0, GR0 //i move GR0, $i move #0, GR1 //S move GR1, $S L1: move $i, GR0 sub #10, GR0 jpgt L2 move $S, GR1 move $i, GR0 add $A(GR0), GR1 move GR1, $S add #1, GR0 move GR0, $i jump L1 L2: halt // i: ds.1 S: ds.1 A: ここからデータが並ぶ メモリ領域の番号 配列 0: move #0, GR0 1: move GR0, $i 2: move #0, GR1 3: move GR1, $S //L1: 4: move $i, GR0 5: sub #10, GR0 6: jpgt L2 7: move $S, GR1 8: move $i, GR0 9: add $A(GR0), GR1 10: move GR1, $S 11: add #1, GR0 12: move GR0, $i 13: jump L1 //L2: 14: halt //i: 20: ds.1 //S: 21: ds.1 //A: 22: ここからデータが並ぶ

  6. メモリ領域の番号 0: move #0, GR0 1: move GR0, $i 2: move #0, GR1 3: move GR1, $S //L1: 4: move $i, GR0 5: sub #10, GR0 6: jpgt L2 7: move $S, GR1 8: move $i, GR0 9: add $A(GR0), GR1 10: move GR1, $S 11: add #1, GR0 12: move GR0, $i 13: jump L1 //L2: 14: halt //i: 20: ds.1 //S: 21: ds.1 //A: 22: ここからデータが並ぶ 0: move #0, GR0 1: move GR0, 20 //$i 2: move #0, GR1 3: move GR1, 21 //$S //L1: 4: move 20, GR0 //$i, GR0 5: sub #10, GR0 6: jpgt 14 //L2 7: move 21, GR1 //$S, GR1 8: move 20, GR0 //$i, GR0 9: add 22(GR0), GR1 //Si(GR0) 10: move GR1, 21 //$S 11: add #1, GR0 12: move GR0, 20 //$i 13: jump 4 //L1 //L2: 14: halt //i: 20: ds.1 //S: 21: ds.1 //A: 22: ここからデータが並ぶ インデックスレジスタ修飾アドレス方式 address resolution L1 -> 4 L2 -> 14 i -> 20 S -> 21 A -> 22

More Related