開發紀錄HW4--開發紀錄(B)

作業要求(B)

  • 改善 JIT compiler,加入若干 optimization techniques
  • 紀錄若干效能最佳化技巧帶來的提昇
 

事前準備:

  • Brainf*ck instructions
Instruction  
C equivalent
Description
>
++p;
Increment the pointer
<
--p;
Decrement the pointer
+
++*p;
Increment the byte at the pointer
-
--*p;
Decrement the byte at the pointer
.
putchar(*p);
Output the byte at the pointer
,
*p=getchar();
Input a byte and store it in the byte at the pointer
[
while(*p) {
Start loop: Execute delimited code until the byte at the pointer equals zero
]
}  
End loop: Jump back to the matching [
  • hello.b
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.-----
                                             H  e       ll   o                     W o   r      l    
---.>+.>.
   d  !
 
c1 += 10;
while(!c1==0){
    c2 += 7;
    c3 += 10;
    c4 += 3;
    c5 += 1;
}                  //after this loop c2=70 , c3=100 , c4=30 , c5=10
c2 += 2;
putchar(c2);      //c2 = 72 , output = H
c3 += 1;
putchar(c3);     //c3 = 101 , output = e
c3 += 7;
putchar(c3);     //c3 = 108 , output = l
putchar(c3);     //c3 = 108 , output = l
c3 += 3;
putchar(c3);     //c3 = 111 , output = o
c4 += 2;
putchar(c4);     //c4 = 32 , output = ' '
c2 += 15;
putchar(c2);     //c2 = 87 , output = W
putchar(c3);     //c3 = 111 , output = o
c3 += 3;
putchar(c3);     //c3 = 114 , output = r
c3 -= 6;
putchar(c3);     //c3 = 108 , output = l