Pyastra ARCHITECTURE (A bit obsolete)
Note: current architecture is temporary and may be changed at
|Pyastra's console front-end
||Converter from tree to assembler
|PIC 16F877 default namespace
(register names, bit names; all in CAPS). Generated by inc2py.py 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 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
is coded into the following:
_a equ 0x37 ;bank -1
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
it "runs" the expression and checks the Z bit of STATUS register. For
will produce the following code:
movf _a, w
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.
btfsc STATUS, Z
The other statements work in the same manner.
About the names and labels
All the labels generated by Pyastra are generated by the following
%i is an unique number (decimal integer).
Other labels are generated when you create a function then it has
All the user's variable names have "_" prefix don't to interfere with
automatically generated names.
To get more details you may do three things:
- Ask me.
- See the sources.
- Try to note what code brings what results
To be continued... :)
$Id: HACKING.html,v 1.3 2004/05/13 21:39:13 estyler Exp $