[Pyastra-general] Re:Finding out more about Pyastra
Status: Alpha
Brought to you by:
estyler
|
From: Alex <es...@ya...> - 2004-04-16 23:57:51
|
Hello,
Current architecture of Pyastra is temporary. First standard python
module "parser" converts given file to a tree. Second stage is made by
tree2tree.py optimizer (currently it does nothing at all). Then it is
converted by tree2asm.py to assembler.
More details is planned to be published at project's homepage near the
release 0.0.1.
As an example i made a classic example (blinking LEDs):
PORTA=fbin('0101 0101')
while (1):
PORTA ^= 0xff
for i in xrange(0, 255):
pass
It is converted to the following PIC16 assebler code:
;
; Generated by pyastra 0.0.1
; infile: tests/hello_world.py
;
processor 16f877
#include p16f877.inc
_lshift_left equ 0x21 ;bank -1
_lshift_right equ 0x22 ;bank -1
_rshift_left equ 0x23 ;bank -1
_rshift_right equ 0x24 ;bank -1
_mul_left equ 0x25 ;bank -1
_mul_right equ 0x26 ;bank -1
mul_cntr equ 0x27 ;bank -1
mul_res equ 0x28 ;bank -1
_div_left equ 0x29 ;bank -1
_div_right equ 0x2a ;bank -1
div_cntr equ 0x2b ;bank -1
div_buf equ 0x2c ;bank -1
_mod_left equ 0x2d ;bank -1
_mod_right equ 0x2e ;bank -1
mod_cntr equ 0x2f ;bank -1
mod_buf equ 0x30 ;bank -1
_pow_left equ 0x31 ;bank -1
_pow_right equ 0x32 ;bank -1
pow_res equ 0x33 ;bank -1
pow_buf equ 0x34 ;bank -1
pow_cntr equ 0x35 ;bank -1
stack0 equ 0x36 ;bank -1
_i equ 0x37 ;bank -1
stack1 equ 0x38 ;bank -1
org 0x0
nop
goto main
org 0x4
main
movlw 0x55
movwf stack0
bcf STATUS, RP0
bcf STATUS, RP1
movwf PORTA
label0
movlw 0x1
movwf stack0
btfsc STATUS, Z
goto label1
movlw 0xff
movwf stack0
bcf STATUS, RP0
bcf STATUS, RP1
xorwf PORTA, f
clrf _i
movlw 0xff
movwf stack1
movwf stack0
label2
movf stack0, w
subwf _i, w
btfsc STATUS, Z
goto label3
btfsc STATUS, C
goto label3
label4
incf _i, f
goto label2
label3
goto label0
label1
goto $
end
And that's the output of Pyastra:
Peak RAM usage: 25 byte(s) (6.8%)
Program memory usage: 30 word(s) (0.4%)
NOTE: statistics includes ICD memory usage!
Best regards,
Alex Ziranov.
Wise Jeff-Q16332 wrote:
> Hi,
>
> I'm interested in finding out more about Pyastra and how it works.
For example, what
> python code would translate to what PIC code.
>
> Thanks,
> ...Jeff Wise
|