assembly - Why is Microchip XC8 writing .as file that complicated? -


I am setting the code below, then the second, then the third and end, the fourth bit of the TRIS register . Why is the generated assembly code that ... strange ?

Good to know: Data collection of microcontrollers that has been compiled for the code is divided into several banks, in the status code 6 and 7, status code 5 and 6 in status register, Only accumulated in 0-5 OPCDs. 6 .

Specific question:

    6
    • (134) ^ 080 : this 6 < / Code>, which detects TRIS on that particular bank compiler bus (6) or (134) write Why not? Is it just to clarify that TRIS Bank is not on 0, or is there any other reason?
    • + (0/8) : 0 the state of the bit in that position, 8 the total number of that bit In my view, this expression does not serve any purpose because the result is always a fraction, never an integer. Therefore, it does not contribute to ad count.
    • (0) & 7 : (0) stands again for bit position, but whose purpose is to create a binary- and with 7 works, I'm not clearly ambiguous.
    • What does the line command do?

    code (exiting from generated * .as file)

     ; Main.c: 9: TRISB | = 1; BSF status, 5; Select RP 0 = 1, Bank 1 BCF status, 6; RP1 = 0, select bank 1 BSF (134) ^ 080H + (0/8), (0) and 7; Volatile line 10; Main.c: 10: TRISB | = 2; BSF (134) ^ 080H + (1/8), (1) and 7; Volatile line 11; Main.c: 11: TRISB | = 4; BSF (134) ^ 080H + (2/8), (2) and 7; Volatile line 12; Main.c: 12: TRISB | = 8; BSF (134) ^ 080H + (3/8), (3) and 7; Volatile line 13  

I'm not really familiar with the XC8 compiler or PIC architecture Can not say to ensure that the compiler is emitting (134) ^ 080 , but it should make the assembly easy to read, shows the desired address if it is just 6 You have to go back to the assembly and see what the actual address is, find out For that status was modified in the final form.

For your other questions, it is easy to answer. The reason for continuous dividing and masking of bit position is that the same instruction template can be used to set the bits larger than a byte. Consider that you were writing a function that prints a assembly instruction that sets some in memory space. In a way, you can write it:

  zero emit_set_bit_insn (char const * addr, int bit) {printf ("BSF% s + (% d / 8), (% d) Amp; 7 \ n ", adr, bit, bit); }  

Now consider that the emit_set_bit_insn ("var16", 10) will output:

  bsf var16 + (10 / 8), (10) and 7  

which will evaluate as code:

  bsf var16 + 1,2  

which sets bit 2 in the second byte of var16 , which is similar to setting bit 10 of 16-bit variable var16 (well From ... assuming a bit byte command, which apparently belongs to the XC8 compiler.)

Make sure the compiler does all arithmetic It is not, however, that the code of the compiler will be very easy assembler to generate the same machine code in any way.

As Kiril has suggested that the line instruction is not a assembly instruction. It is used to inform the CDL, which is in the C source code to cooperate with the following sources. The debugger can use the program to display the relevant source code for the given address, the coder will use this information to generate debugging information.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -