February 28, 2013

Kernel coding standard

Kernel coding standard published on kernel.org differs from others by style which is used there. It made me smiled during reading, following lines are copied from it :

"However, if you have a complex function, and you suspect that a
less-than-gifted first-year high-school student might not even
understand what the function is all about"

Overall, there are many "weak" points highlighted there which should be considered.

Coding style [kernel.org]

February 17, 2013

Reciprocal multiplication

I have posted here links which were dedicated to the multiplication and division. I had to get back to it today because was not sure what does constant mean in one assembly code (0x199A).

Reciprocal Multiplication [homepage.cs.uiowa.edu/~jones]
Here was the answer to that constant, why to use fixed point arithmetic on dividing, also explanation why 0xCCCD is used to calculate 1/10 of a value.

I am glad it brought up the topic back and I had to revise it.

February 6, 2013

Sublime Text 2 for C/C++ development

I've decided to use VIM for my development. Although I installed it long time ago, I have not gave it a shot. On the other hand, I started using Sublime. The beginning was like notepad++ feeling, what does sublime offer more, I marveled. That's been itching my conscience and therefore I watched few tutorials and opened Sublime Text Cheat Sheet. Since that moment, I've pleasantly been using it with much more effectivity. Here I present most used shortcuts which makes my development faster ( take it as is, because I am still learning).

This document covers a lot, but I recommend to watch tutorials
Tutplus.com Sublime [tutsplus.com]

After you complete it, check this and write down (memorize) which you consider important.
Sublime Text Cheat [pastebin.com]

Plugins make sublime powerful, I use so far these - Linter (with cppcheck), CodeIntel, Bracket Highlighter.

The only problem I had, was to set up cppcheck in Linter, paste this into user settings for Linter (path to cppcheck)

"sublimelinter": "load-save",

"sublimelinter_executable_map": {

"c" : "C:/Program Files/Cppcheck/cppcheck.exe",

"c++" : "C:/Program Files/Cppcheck/cppcheck.exe"


"sublimelinter_gutter_marks": true,

"sublimelinter_popup_errors_on_save": true,

"sublimelinter": "save-only"


Happy coding and don't use a mouse, use a keyboard with shortcuts!

February 4, 2013

ARM compiler (armcc) and ARM archiver (armar)

I usually create libraries with an extension .a or .lib. As I glanced at mbed, their own library has extension .ar. KEIL comes with ARM Compilation Tools [www.keil.com]), which is used also for embed library, as I believe.

To compile files from which we want to create a library (target is Cortex-M0+).
armcc --cpu=Cortex-M0plus --no_debug -c file1 file2 fileXY

To create static library from object files
armar --rv archive_name object_file1 object_file2 object_fileXY

I successfully imported small static library to mbed and run it on my mbed board. There are many options to select. To read more here are the links:

Creating static software libraries with armar (pdf) [infocenter.arm.com/help]
Getting Started with the Compiler [keil.com]

February 2, 2013

Optimalization + aliasing in C programs (bookmark)

An article about pointer aliasing, using local variables over global and few more tips.

Optimizing C programs [eetimes.com]


There was a demand to process all testing data and generate graphs. There was a perl script to process everything but was outdated. To plot the graphs it used GNUplot. I found lack of documentation, although everything I found on the internet (blogs, stackoverflow). What my parser required was to use multiplot to generate 3 rows and 2 colums graphs, read data from files.  The each column has to have own title above them.

GNUplot is really powerful and I will be happy to use it once again.