Keil uVision compiles my code into 0xfff-s - arm

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

Related

ISR declaration for LPC2148 in gcc compiler

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 :)

Every IDE falls into disassembly mode during debugging

I have installed Linux (Ubuntu 16.04) recently, then QtCreator. Every time when I try to debug my C program in it, it falls into disassembly mode, it means when I try to step into, or even step over, it opens a file "Disassasembly(...)" and navigates in this file. It happens not only for standard functions like malloc (which source code I don't have), but also for my own functions. I thought it's because of the IDE, and installed NetBeans - and I have exactly the same problem in it.
Some example:
[it is shown after stepping over my function, and this function is just the beginning of my program, but the program ends after this screen] - edit: sorry I had to remove this file, because I can post only 2 links..
Another problem is when even for a short moment it navigates on my code (not on disassembly), it executes lines which contains documentation, and gets out to the body of another fuction, which isn't called by me at all(!) It looks like a mess...
So, I think it might be some problem with GDB, but I have no idea how to solve it. Could you help me?
GDB v. 7.11.1
gcc v. 5.4.0
NetBeans v. 8.2
EDIT: It became really weird. Today, when I tried to debug it once again, without any changes in code nor settings, the debugger started to behave almost normally, it means, that it steps through my code correctly now. The only moment, when it falls into dissasembly mode, is the end of my program, when last instruction has executed and it should end. This screens should help:
(1)
(2)
EDIT2: Ok, maybe it is quite normal now. But I still have no idea, what was wrong, and what solved the problem. I hope that it won't come back :)

Run dynamically generated assembly in C (GNU/Linux)

I'm writing a proof-of-concept JIT compiler in C, which at the moment is generating strings of assembly code. The inline assembly functionality in C only deals with string literals that are known at compile time, so I can't use it to run my generated-at-runtime code.
I've read about using mmap() to execute generated machine code at runtime, but I'd like to avoid working with machine code if possible.
Does anyone know of any solutions? I've thought of writing it to a file and invoking the assembler & linker on said file, but that'd be messy and slow.
I think ultimately to be "JIT" you need to be time sensitive which means generate machine code. You might try putting in some debug code that generates both machine code to run and assembly code to verify, run the assembler compare the machine code from the assembly language to the machine code you generated directly and use that to debug/validate the machine code (if possible, sometimes assemblers want to do their own thing, not what you wanted them to do).
What I've done is generate C/C++/Fortran code, compile it on the fly, link it into a DLL, and dynamically load the DLL, all of which takes on the order of a few seconds at most.
You could do the same, except generate ASM.
It's a very effective technique when you need speed of the resulting code, plus the flexibility of the code (and run-time libraries) of the language you're generating.

System calls not working in Atmel AVR Studio (with ASF)

I am not getting answers on the AVR Freaks forum and wonder if someone here could help me.
The answer might lie in this SO question, but I am not sure why it would be necessary.
Basically, I have my fist ever Atmel project (AVR studio 6, UC3 processor). The code compiles and links and I can load it to the Atmel board and step through in the debugger.
However, when I try to step over (or run until a breakpoint on the line after) a (valid) call to sprintf(), malloc() or memcpy() (there may be more, which I have not yet discovered), the IDE never returns to the next line of my code, just seeming to hang, or run forever.
[Note] Compiler optimization is off
Do I need to set some linker options (e.g link static (which I tried & it didn't help)? Or build with some library?
What confuses me is that the code compilers and links - what is being linked when I call these standard functions? If I need something else I would expect a compiler or linker error, but get none - so why won't my code run?
Sorry for such a stupid n00nb question, but it is my first micro-controller project.
I discovered that the CPU on my board is an Engineering Sample and not supported by Atmel Studio without a new io.h file.
I sort of figured that out from this question: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=106652
Sorry to have troubled you.
what is being linked when I call these standard functions?
The AVR-libc, the implementation of the C standard library ported to the AVR platform.
so why won't my code run?
Compiler errors and runtime errors are not even related. Both of these lines are valid C and they compile, however, on most systems, I'd expect them to dump core:
int x = 1 / 0;
*(int *)0 = 41;
So it might be either:
a bug in the standard library (very unlikely), or
a bug in the online debugger (very unlikely), or
maybe you just expect something that is not supposed to happen?
Instead of trying to step over, what happens if you set a breakpoint at next line after the line you want to step over?
Also, does the operation change if you turn off compiler optimization?

ARM (thumb) firmware mod...how to turn few lines of ASM to code to make a mod

Have firmware disassmbled with IDA (ARM920 Core).. most is Thumb mode....some is ARM mode
Want to make some mods, in ASM.
What is the easiest way to turn few lines of ASM (well few dozen) into machine language.
Can some one suggest a FREE tool / how to.
I just downloaded WinARM. Comes with Programmers Notepad. Been few hours now, trying to make sense of it all... just to compile a few lines of ASM... and the MAKE file i made, is still not working (some thing about end of line)
A tool that turns assembly code into machine code is called an assembler. Any of the usual toolchains include one. For ARM, you can try good old gcc. Source & binaries available: http://www.gnuarm.com/
Running the assembler should be as easy as:
gcc -o example.o example.s
You'll have to replace gcc in the example with the name of your cross-compiler. I think the one from the link I have above is arm-elf-gcc.

Resources