12.07.2015 Views

MAXQ Core Assembly Guide - Maxim

MAXQ Core Assembly Guide - Maxim

MAXQ Core Assembly Guide - Maxim

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>MAXQ</strong> <strong>Core</strong> <strong>Assembly</strong> <strong>Guide</strong>The opcode, if included, must be one of the standard <strong>MAXQ</strong> assembly opcodes as defined in the <strong>MAXQ</strong> FamilyUser’s <strong>Guide</strong>. Opcodes in MaxQAsm are also, case-insensitive, so “addc”, “AddC” and “ADDC” are all equivalent.Each opcode has from zero to two parameters.If the semicolon character “;” is included in the statement line, all text following this character is treated as acomment and will be ignored by both Macro and MaxQAsm. Comments are limited to a single line only.The final line in each assembly source file must consist of the END directive, as follows.endGlobal and Local LabelsIn <strong>MAXQ</strong> assembly, labels mark a point in the assembly code which can be used as a destination for a JUMP orCALL or as a reference point when reading data from code space. There are two types of labels which can beused – global and local.Global labels are defined as described above under “General Syntax”, and consist of an identifier followed by acolon (“:”). This type of label has global scope, which means that it can be referenced from any point at any file inthe assembly project.callSub1Sub1:push Accadd #1ret; This label can be referenced from anywhereGlobal labels are useful when defining entry points for subroutines and reference points for global strings and tabledata, since they allow the labels to be referenced from anywhere in the project. However, in some cases it is moreuseful for a label to have a more limited scope. For example, subroutines often contain labels in order toimplement loops or other control structures within the subroutine. In general, these labels are for the use of thesubroutine only and are not intended to be used by code outside the subroutine, but with global labels, there is noway to prevent such external use. Additionally, care must be taken when defining labels within subroutines to keepthe names unique and avoid collisions with labels defined inside other subroutines, which often leads to code suchas the following.transmitBytes:move LC[1], #10 ; Number of bytes to transmitmove Acc, #07htransmitBytes_loop: ; Make sure this name is uniquecall sendNextBytedjnz LC[1], transmitBytes_loopLocal labels solve both of these problems by providing a way to define labels that are only visible within asubroutine or other limited scope section. These labels are defined in the same way as global labels, except theyalways start with a period (“.”). Local labels operate exactly the same as global labels, except for their scope.Instead of being visible throughout the entire project, the scope of local labels is restricted to the space betweenone global label and the next. This allows labels to be defined which are only accessible within a subroutine orother code block and have no potential for colliding with labels defined elsewhere.Note: In order to use local labels, you must be running maxqasm version 2.042 or later, since this feature was notdefined in previous versions.Version 1.2 7 of 43 March 7, 2007

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!