I am working on simple calculator on altera De2-70 board, using altera monitor program. i am continuously getting errors for syntax in c on altera monitor program. does it use different syntax or just same as c programming?
i did the system design on Qsys and it generates the system without errors. Even i tried a simple blink using switches it worked. but here i am using pointers to get in put from 8 - switches, 8 bits, 6 bits for 2 numbers,3 bit for each,then bit mask to for number assigning and do math in c with decimal numbers, then convert decimal to binary with c on altera monitor program
#define switches (volatile char *) 0x0002000
#define leds (char *) 0x0002010
void main(){
char op;
int i;
int A;
int B;
int lights;
while(1)
if(*switches & 10000000 ){
op ='+';
}
else if(*switches & 01000000){
op ='-';
}
else if(*switches & 00000001){
B = 1;
}
else if(*switches & 00000010){
B = 2;
}
else if(*switches & 00000011){
B = 3;
}
else if(*switches & 00000100){
B = 4;
}
else if(*switches & 00000101){
B = 5;
}
else if(*switches & 00000110){
B = 6;
}
else if(*switches & 00000111){
B = 7;
}
else if(*switches & 00001000){
A = 1;
}
else if(*switches & 00010000){
A = 2;
}
else if(*switches & 00011000){
A = 3;
}
else if(*switches & 00100000){
A = 4;
}
else if(*switches & 00101000){
A = 5;
}
else if(*switches & 00110000){
A = 6;
}
else if(*switches & 00111000){
A = 7;
}
switch(op) {
case '+:
lights = A+B;
break;
case '-:
lights = A-B;
break;
default: *leds = *switches;
}
while(lights!=0){
leds[i++] = lights % 2;
lights = lights / 2;
}
}
/* //the worked simple blink code
#define switches (volatile char *) 0x0002000
#define leds (char *) 0x0002010
void main(){
while (1)
*leds = *switches;
}*/
i did the system design on Qsys and it generates the system without errors. Even i tried a simple blink using switches it worked. but here i am using pointers to get in put from 8 - switches, 8 bits, 6 bits for 2 numbers,3 bit for each,then bit mask to for number assigning and do math in c with decimal numbers, then convert decimal to binary with c on altera monitor program
#define switches (volatile char *) 0x0002000
#define leds (char *) 0x0002010
void main(){
char op;
int i;
int A;
int B;
int lights;
while(1)
if(*switches & 10000000 ){
op ='+';
}
else if(*switches & 01000000){
op ='-';
}
else if(*switches & 00000001){
B = 1;
}
else if(*switches & 00000010){
B = 2;
}
else if(*switches & 00000011){
B = 3;
}
else if(*switches & 00000100){
B = 4;
}
else if(*switches & 00000101){
B = 5;
}
else if(*switches & 00000110){
B = 6;
}
else if(*switches & 00000111){
B = 7;
}
else if(*switches & 00001000){
A = 1;
}
else if(*switches & 00010000){
A = 2;
}
else if(*switches & 00011000){
A = 3;
}
else if(*switches & 00100000){
A = 4;
}
else if(*switches & 00101000){
A = 5;
}
else if(*switches & 00110000){
A = 6;
}
else if(*switches & 00111000){
A = 7;
}
switch(op) {
case '+:
lights = A+B;
break;
case '-:
lights = A-B;
break;
default: *leds = *switches;
}
while(lights!=0){
leds[i++] = lights % 2;
lights = lights / 2;
}
}
/* //the worked simple blink code
#define switches (volatile char *) 0x0002000
#define leds (char *) 0x0002010
void main(){
while (1)
*leds = *switches;
}*/