Document fait avec Nvu Document made with Nvu
acceuilnouveautesintroductioncoeurmini_systemepages_techniquesrevue_de_presselienscourriel



Technical pages
16 bits PIC and dsPIC assembler

Instructions
Use
Example

Principle

The assembler is a compiler which allows to write a program by using the specific instructions of the microprocessor being of use as the computer core. The assembler is indispensable to the writing of the basic instructions of high-level languages (FORTH, Pascal, C, ...) which are so independent from the used platform themselves. To speak more technical, high-level languages are portable while the assembler is not it (unless realize a simulation software).

The purpose of this page is not to list all the instructions of 16 bits PIC and dsPIC processors or to give a manual of it. All that is available in the builder website MICROCHIP.

On the other hand, the contents of this page will allow developers the most warned to realize their own programs in assembler in the environment of the micro system.

Instructions

- RAZ_ASSEMBLEUR -

Allows to initialize again the labels table

- ASSEMBLEUR -

Assembly of the text which follows this instruction until the directive " END "

- [>" chemin/nom" -

Allows to generate a assembled source file for the FORTH micro system.

- FORGET_ASSEMBLEUR -

Allows to remove the instructions set dedicated to the assembler from the vocabulary.


Use

The micro system assembler, only usable with the FORTH Core, is a real assembler 2 passes managing a labels table. As indicated in the corresponding column, it contains only 4 instructions FORTH:

  • RAZ_ASSEMBLEUR erases the labels table. This disappearance is automatically realized in the software installation. It is necessary to execute  this instruction at the beginning of the code source because, in case of assembly again, he will avoid the appearance of the message "Etiquette déjà déclarée"(Label already declared).
  • ASSEMBLER crosses the interpreter FORTH in assembler. From this instruction, the syntax of the following lines has to follow that of the assembler until the appearance of the directive " END " which indicates to the assembler to return to mode interpretation FORTH at the conclusion of the second pass.
  • [>" allows to generate a assembled source file for the FORTH micro system for enhance its real time vocabulary.
  • FORGET_ASSEMBLEUR frees memory occupied by the assembler when this one is not useful any more. The 4 FORTH instructions bound to the assembler will disappear of the vocabulary at the same time as the liberation of the memory space.

Labels have necessarily to begin with a major letter. The following characters can be major letters, numbers or character "_". Not any label has to begin with the same letters as the registers of processors.

  • PIC24x registers: W0 (ou WREG), W1, W2, W3, W4, W5, W6, W7, W8, W9, W10, W11, W12, W13, W14 (ou WFP), W15 (ou WSP), PC, SR,TBLPAG,PSVPAG.
  • dsPIC3x supplementary registers: A,B.
  • PIC24E and dsPIC33E supplementary registers: DSRPAG and DSWPAG unstead of PSVPAG.

The registers of the FORTH micro system PIC and dsPIC are used in the following way:

  • W0 (ou WREG) constitutes the summit of the pile of data,
  • W15 (ou WSP) constitutes the pointer of the return stack,
  • W14 (ou WFP) constitutes the pointer of the data stack (he points so the 2-nd element),
  • The other registers are free.

Instructions must be written in major letters. Syntax is the same as MICROCHIP. The addressing modes are the following ones:

  • PIC: Wn; [Wn]; [Wn--]; [Wn++]; [--Wn]; [++Wn]; [Wn+Wm]; [Wn+lit]; f; #lit; #bit; Expr; rPAG.
  • dsPIC supplements: Acc; Wn*Wn; Wn*Wm; [Wn+=d]; [Wn-=d].
There is an assembly directive allowing to filter the instructions function of the choosen core:
  • PIC24F or PIC24H (default core),
  • PIC24E,
  • DSPIC30F or dsPIC33F,
  • DSPIC33E.

Example

To illustrate this presentation, nothing is worth a good example. This one is available under shape of text file: sqrt_source.txt.

It is about a program allowing the origin of the square root of an unsigned 16 bits integer (SQRT) and 32 bits (DSQRT).

The result is the file sqrt.txt downloadable in the FORTH micro system via its communication serial link.