Pyastra ARCHITECTURE (A bit obsolete)

current architecture is temporary and may be changed at any moment!

Pyastra's console front-end Tree optimizer Converter from tree to assembler
PIC 16F877 default namespace (register names, bit names; all in CAPS). Generated by script.
PIC 16F877 specific built-ins. Is imported by Pyastra in all files (when compiling for this microcontroller). Includes microcontroller-specific functions like multiplication, division, power, etc)

First standard python module "parser" converts given file to a tree. Second stage is made by optimizer. Then it is converted by to assembler.

More details about tree2asm

All the commands deal through W register. For example, code a=5 is coded into the following:
_a      equ     0x37    ;bank -1

movlw 0x5
movwf stack0
movwf _a
First it reserves memory in bank-independent part (that bank -1 notes), then it puts the constant in the work register W, then it checks weather it's zero (see below) and the last thing it puts the value into the corresponding memory cell.

When this module needs to check some statements (e. g. for if), it "runs" the expression and checks the Z bit of STATUS register. For example, code
if a:
will produce the following code:
        movf    _a,     w
btfsc STATUS, Z
goto label0
clrf _a
First line puts the value of register _a into W register (as if we wrote in that line simply "a" without if). Then it checks Z bit. If it's cleared, then W register is true (not equals to zero). That means that the body should be run. Otherwise it jumps to label0. The body is simple: to clear register a.

The other statements work in the same manner.

About the names and labels

All the labels generated by Pyastra are generated by the following template:
where %i is an unique number (decimal integer).

Other labels are generated when you create a function then it has "func_" prefix.

All the user's variable names have "_" prefix don't to interfere with automatically generated names.

More details

To get more details you may do three things:

To be continued... :)

$Id: HACKING.html,v 1.3 2004/05/13 21:39:13 estyler Exp $