When I compile my code I am getting a unknown Opcode '.pword' error. The only line of code in my project that has .pword is:
do {
__asm__ volatile (" .pword 0xDA4000");
Nop();
} while(0)
Commenting the line out does nothing.
I searched .pword 0xDA4000 and know it is supported by the IDE MPLab for PICs.
In my case the IDE I am using is CrossStudio for a STMf32f2xx chip.
I have the updated CrossStudio which comes with binutils 2.21 and gcc 4.6.0
I initially had a problem with compiling unnamed structs and unions but adding -fms-extensions into additional C compiler options fixed it.
I dont know if I need to do something similar to fix Opcode '.pword' error.
could it just be that .pword is only a PIC opcode?
In MPLAB ASM30 assembler the .pword declare 24 bit constant in code memory. It can be also any MPLAB ASM30 instruction.
Check: MPLAB ASM30 assembler
Related
I am new to gcc compiler and I am trying to compile code for LPC2148 using gcc compiler on mac m1. As per suggestions by some answers, I am using attribute((interrupt("IRQ"))) instead of __irq.
When I am compiling, there is no error and hex file is getting generated. However, the code written in interrupt Service Routine is not at all executing.
Can some one please help me here. I am completely fed up by searching solution for this.
Thankyou :)
I am working on a project using an ATtiny 202 and I am nearly done with my programming, but I have run into a large problem. I can't create any ISRs, because I always get a compiler error.
I am using the newest version of MPLABX IDE (5.35) (yes it is for pic and avr mcus) and the second newest version of the xc8 compiler (v2.10). I cannot use the newest version of the compiler, because that is for some reason missing the device header for the ATtiny 202. (I had a different thread about that problem a while ago)
I have created the ISRs exactly like described in the XC8 Manual, and the IDE doesn't mark it as a problem either, but when I then try to compile the program I always get a compiler error.
Here is one of my ISRs:
void __interrupt (RTC_PIT_vect_num) pit_int(void){
onPIT(); //Run the function
RTC.PITINTFLAGS = 0x0; //and clear the interrupt flags
}
The IDE marks the RTC_PIT_vect_num blue and correctly recognizes it, as it is defined in the device header.
When I try to compile it, I get this error message, and the build fails:
main.c:864:19: error: expected declaration specifiers or '...' before numeric constant
void __interrupt (RTC_PIT_vect_num) pit_int(void){
^
I dont know what exactly the problem is and how to solve it.
For comparison, here is an example from the "XC8 User Guide for AVR", page 83:
void __interrupt(SPI_STC_vect_num) spi_Isr(void) {
process(SPI_SlaveReceive());
return;
}
As you can see, the structure of the function is exactly the same as in my own ISR.
Does someone have an idea what the problem is or may be and how to fix it?
Fixed:
I had posted this question on the microchip forum as well, as no one here seemed to be able to help.
So I figured out that the problem was that in the project properties under
XC8 Global Options -> XC8 Compiler -> Option categories: Preprocessing and messages
the option "Use CCI Syntax" was disabled. This needs to be enabled for the __interrupt to work.
I have a weird problem. For some reason, my compiler generates 0xfff-s instead of real code. This happens for a whole file (see screenshot, sim800.c is whole like this), other files are compiled fine.
This does not necessarily happens to this particular file. If I change the code, the sim800.c would compile fine, but some other one would be wrong.
This happens only if optimization if off (-O0) If I turn on optimisations (-O1) the problem disappears. Clean-compile does not help.
C code along with its assembly
I'm using
Keil uVision 5
GCC v5.06 upd. 1
STM32F030
I have a project written in C that originally was being done on Linux, but now must be done on Windows. Part of the code include this line in several places
asm("movl temp, %esp");
But that causes an "undefined reference to `temp'" error.
This has no problem compiling on Linux using the gcc 4.3.2 compiler (tested on another machine), which is the version I have on Cygwin. Is there another way to accomplish what this line is doing?
You need to change the cygwin version from
asm("movl temp, %esp");
to
asm("movl _temp, %esp");
Yes, it's the same compiler and assembler but they are set up differently for compatibility with the host system.
You can isolate the system-dependent symbol prefixing by simply telling gcc a specific name to use:
int *temp asm("localname");
...
__asm__("movl localname,%esp");
This avoids an #if of some sort and removes a host OS dependency but adds a compiler dependency. Speaking of compiler extensions, some people would write (see info as) something like:
#ifdef __GNUC__
__asm__("movl %[newbase],%%esp"
:
: [newbase] "r,m" (temp)
: "%esp");
#else
#error haven't written this yet
#endif
The idea here is that this syntax allows the compiler to help you out, by finding temp, even if it's lying about in a register or takes a few instructions to load, and also to avoid conflicting with you, it case it was using a register you clobbered. It needs this because a plain __asm__() is not parsed in any way by the compiler.
In your case, you seem to be implementing your own threading package, and so none of this really matters. Gcc wasn't about to use %esp for a calculation. (But why not just use pthreads...?)
Silly question, but I just can not find the necessary flag in gcc. Basically, I have in my C program the following inline assembler code
__asm__ __volatile__ ("lea ebx, [timings] \n\t");
When compiling, I get an errormessage which says: Error: invalid char '[' beginning operand 2[timings]'`
Now I remember that a long time ago I used some kind of flag that told the compiler that it is x86 inline assembly. But cant find it online, could maybe someone please tell me which flag i have to use?
Thank you so much!
You can't specify variables that way with GCC. See this document for a detailed description of how to use inline assembler. Also, keep in mind that GCC uses AT&T syntax, not Intel syntax, so you have to put your destinations on the right.
Try using __asm__ instead. Look here for more.
Also, try removing the \n\t from inside the assembly code.