Pyastra ARCHITECTURE (A bit obsolete)


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

File
Description
pyastra
Pyastra's console front-end
tree2tree.py Tree optimizer
tree2asm.py Converter from tree to assembler
regs16f877.py
PIC 16F877 default namespace (register names, bit names; all in CAPS). Generated by inc2py.py script.
p16f877.py
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 tree2tree.py optimizer. Then it is converted by tree2asm.py 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:
a=0
will produce the following code:
        movf    _a,     w
btfsc STATUS, Z
goto label0
clrf _a
label0
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:
label%i
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 $