Positron Compiler Documentation

Asm..EndAsm

Source: Positron8 Compiler User Manual, PDF page 416

Syntax

Asm

assembler mnemonics

EndAsm

or

@ assembler mnemonic

Overview

Incorporate in-line assembler in the BASIC code. The mnemonics are passed directly to the assembler without the compiler interfering in any way. This allows a great deal of flexibility that cannot always be achieved using BASIC commands alone.

When the Asm directive is found within the BASIC program, the RAM banks are reset before the assembler code is operated upon. The same happens when the EndAsm directive is found, in that the RAM banks are reset upon leaving the assembly code. However, this may not always be required and can waste precious code memory.

Placing a dash after Asm or EndAsm will remove the RAM reset mnemonics.

Asm-
EndAsm

Only remove the RAM resets if you are confident enough to do so, as PICmicro™ devices have banked RAM.

The compiler also allows simple assembler mnemonics to be used within the BASIC program without wrapping them in Asm-EndAsm, however, the constants, labels, and variables used must be valid BASIC types:

Dim MyVar As Byte
Movlw 10
Movwf MyVar

Note. It is important to remember that mnemonics within the BASIC program will not manipulate RAM banks or Flash pages, as the high level commands do, so always us with caution, and understand the RAM and flash fragmentation of the device being used.

If assembler mnemonics are used within a procedure, the local and parameter variables will be presented to them raw, so the procedure’s name will need to be prefixed to a local or parameter or return result variable’s name.

For example:

Proc MyProc(pParam1 As Byte), Byte
    Movf MyProcpParam1,w
    Movwf MyProcResult
EndProc