วันพฤหัสบดีที่ 20 พฤษภาคม พ.ศ. 2553

การใช้ & operator ใน C++

โอเปอเรเตอร์ & ใน c++ อาจหมายถึง address หรือการอ้างอิงก็ได้ compiler c++ จะตีความหมายของ & operator โดยดูจากเนื้อความของประโยคนั้นๆ

ตัวอย่าง 1: ในประโยคต่อไปนี้ & operator ใช้ในการสร้างตัวแปรแบบอ้างอิง(Reference Variable) หรือก็คือ Alias Variable นั้นเอง

int &iAccount = iMyVariable;

ตัวอย่าง 2: ในประโยคต่อไปนี้ & operator ใช้หา Address ของตัวแปร

cout << “Address of iMyVariable = “ << &iMyVariable

วันจันทร์ที่ 10 พฤษภาคม พ.ศ. 2553

Fibonacci in Assembly

INCLUDE Irvine32.inc

          .data

         .code

main PROC

          mov ecx,7

          mov eax,0

          mov ebx,1

          mov edx,eax

          add edx,ebx

          call writedec

          call crlf

          xchg eax,ebx

          call writedec

          call crlf

          xchg ebx,eax

          mov eax,edx

          call writedec

          call crlf

l1:     mov edx,ebx

          add edx,eax

          mov eax,edx

          call writedec

          call crlf

          xchg ebx,eax

          loop l1

          exit

main ENDP

          END main