SỰ KHÁC BIỆT GIỮA định nghĩa và macro 493 mà không phải là rất hữu ích, dễ hiểu mà không có một tham chiếu đến các chân được tổ chức. Trong khi đó, các chỉ dẫn tương tự với Serflag các định nghĩa, nghĩa là,Điều này có thể gây ra một số khác biệt tinh tế có thể là một vấn đề nếu bạn không biết những gì bạn đang làm | Simpo PDF Mei-ge and Split UnregisteredfVersion-Thttp www-simpopdf-com93 which is not very helpful or easy to understand without a reference to how the pins are organized. In comparison the same instruction with the Serflag define . bsf Serflag is much easier to understand without the aid of documentation or even descriptive comments. The single define eliminates remembering or looking up where the bit is located and which bit it is. When reading the code using the define directive enhances the readability of the purpose of the instruction over the actual source information. Defines work because they directly copy in the string and let the assembler evaluate it. This is different from equates which evaluate a string and store it as a constant referenced to the label. This can cause some subtle differences that can be a problem if you don t know what you are doing. For example if you had the code variable A 37 Variable is a run time variable Testi equal A 5 Testi i85 define Test2 A 5 Test2 is Evaluated when it is used A A 5 A 42 movlw Testi Testi is replaced with i85 movlw Test2 Test2 is replaced with A 5 42 5 2i0 in this case even though Testi andTest2 are declared at the same point in the code identically they are evaluated differently and will be different values in different locations of the application. This is a very useful capability but one that can be a problem elsewhere. In the sample code above I declared the variable to be A. Variable is an MPASM directive to create a temporary storage value during the application s assembly and will be discussed in the later sections of this chapter. When it is used in Testi the value of A when the assembler processor encounters the statement is used multiplied by 5 and assigned to Testi. After Testi and Test2 are defined in the code A is modified which results in a different value being calculated for Test2 when it is used later in the application. A useful function that defines can provide is that they can provide