C Programming thread
>>58606832
is Programming in C by Kochan a good book for a noob?
Also how can I learn about debugging, reverse engineering, disassembling, etc?
>>58607760
>is Programming in C by Kochan a good book for a noob?
yes
>>58607760
>Also how can I learn about debugging, reverse engineering, disassembling, etc?
you'll know how to do all of this and more when you're no longer a noob. practice the things you want to learn.
>>58607760
>is Programming in C by Kochan a good book for a noob?
the best book is the book you work through and do all the practice problems.
Why haven't you guys upgraded to C++ yet?
>>58607859
we are aware of C++'s many advantages in specific scenarios. this is a thread about programming in C.
i'm trying to blink the led's on a TI MSP-EXP430G2. Using Linux packages, etc. Getting the following error:make
msp430-elf-gcc -Os -Wall -g -mmcu=msp430x -c main.c
main.c:30:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
void main(void) {
^
In file included from /opt/ti/mspgcc/msp430-elf/include/msp430g2553.h:120:0,
from main.c:19:
main.c: In function ‘main’:
main.c:40:20: error: expected expression before ‘__asm__’
__bis_SR_register(LPM0 + GIE); // LPM0 with interrupts enabled
^
....
this means there is an error with the header files I installed via my package manager, correct? What is the best way to get this fixed?
>>58608119
Post code of invocation and function declaration please. What's the type of variables declared?
>>58608119int main(void) {
...
...
return 0;
}
will fix the compiler errer, but it may be caused by something else
>>58608267//#include <msp430g2553.h> // chip on board has M430G2553 on it.
#include <msp430xgeneric.h>
#include <signal.h> // not sure what this is for
// Need some define statements for the LEDs... not sure how to figure this out
// Copying from other program, but on board P1.0 says LED1, and P1.6 says LED2
#define LED0 BIT0
#define LED1 BIT6
#define LED_DIR P1DIR
#define LED_OUT P1OUT
// I don't understand |=, which is Bitwise inclusive OR and assignment operator.
void main(void) {
WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer?
LED_DIR |= (LED0 + LED1); //Set LED pins as outputs
LED_OUT &= ~(LED0 + LED1); //Turn off both LEDs
CCTL0 = CCIE;
TACTL = TASSEL_2 + MC_2; //Set the timer A to SMCLCK, Continuous
__enable_interrupt();
__bis_SR_register(LPM0 + GIE); // LPM0 with interrupts enabled
}
// Timer A0 interrupt service routine. No idea what pragma is
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void) {
timerCount = (timerCount + 1) % 8;
if(timerCount == 0)
P1OUT ^= (LED0 + LED1);
}
>>58608298
This is silly, but putting a return; at the end of main, wouldn't do anything would it?
>>58608386
it wouldnt make the function behave differently
>>58608298
LED_DIR |= (LED0 + LED1);
means LED_DIR becomes equal to the bitwise OR of LED_DIR and (LED0 + LED1)
#pragma is a directive to the compiler. it isnt standard C but compiler specific.
>>58608386
i notice the small warnings, etc. but I am trying to figure out if it is something in my program or a problem with the headers included with the package i got them from.