In: Computer Science
The following 3 instances of code was provided by my embedded systems course. Can you explain what is happening in each code segment?
=== code 1 ===
void foo() {
uint8_t a=2;
uint8_t b[]={b0, b1, b2}; // They are the last three digits of your
A#
uint8_t* c=b;
uint8_t* d=&a;
}
=== code 2 ===
__extension__ typedef struct tagT1CONBITS {
union {
struct {
unsigned :1;
unsigned TCS:1;
unsigned TSYNC:1;
unsigned :1;
unsigned TCKPS:2;
unsigned TGATE:1;
unsigned :6;
unsigned TSIDL:1;
unsigned :1;
unsigned TON:1;
};
struct {
unsigned :4;
unsigned TCKPS0:1;
unsigned TCKPS1:1;
};
uint8_t T1CON[2];
};
} T1CONBITS;
volatile T1CONBITS foo;
=== code 3 ===
b6: 00 e0 ldi r16, 0x00
b8: 10 e0 ldi r17, 0x00
ba: 0c c0 rjmp .+24
bc: 81 2f mov r24, r17
be: 90 e0 ldi r25, 0x00
c0: 29 81 ldd r18, Y+1
c2: 3a 81 ldd r19, Y+2
c4: 82 0f add r24, r18
c6: 93 1f adc r25, r19
c8: fc 01 movw r30, r24
ca: 80 81 ld r24, Z
cc: 08 0f add r16, r24
ce: 81 2f mov r24, r17
d0: 11 e0 ldi r17, 0x01
d2: 18 0f add r17, r24
d4: 13 30 cpi r17, 0x03
d6: 90 f3 brcs .-28
=== code 1 ===
void foo() {
uint8_t a=2;
uint8_t b[]={b0, b1, b2}; // They are the last three digits of your
A#
uint8_t* c=b;
uint8_t* d=&a;
}
=== code 2 ===
__extension__ typedef struct tagT1CONBITS {
union {
struct {
unsigned :1;
unsigned TCS:1;
unsigned TSYNC:1;
unsigned :1;
unsigned TCKPS:2;
unsigned TGATE:1;
unsigned :6;
unsigned TSIDL:1;
unsigned :1;
unsigned TON:1;
};
struct {
unsigned :4;
unsigned TCKPS0:1;
unsigned TCKPS1:1;
};
uint8_t T1CON[2];
};
} T1CONBITS;
volatile T1CONBITS foo;