asm Statement

mikroBasic PRO for ARM allows embedding assembly in the source code by means of the asm statement. Note that you cannot use numerals as absolute addresses for register variables in assembly instructions. You may use symbolic names instead (listing will display these names as well as addresses).

You can group assembly instructions with the asm keyword:

asm
   block of assembly instructions
end asm

The only types whose name remains the same in asm as it is in the mikroBasic PRO for ARM are registers, e.g. GPIO_PORTB, etc.

Basic comments are allowed in embedded assembly code, along with one-line assembly comments starting with semicolon.

Accessing variables

Depending on the place of declaration, accessing a variable can be done in several ways :

Asm code and SSA optimization

If asm code is mixed with the Basic code, keep in mind that the generated code can substantially differ when SSA optimization option is enabled or disabled.
This is due to the fact that SSA optimization uses certain working registers to store routine parameters (W10-W13), rather than storing them onto the function frame.

Because of this, user must be very careful when writing asm code as existing values in the working registers used by SSA optimization can be overwritten.
To avoid this, it is recommended that user includes desired asm code in a separate routine.

Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code