Shop OBEX P1 Docs P2 Docs Learn Events
Propel (Propeller Assembler Helper) — Parallax Forums

Propel (Propeller Assembler Helper)

LucidGuppyLucidGuppy Posts: 32
edited 2007-09-07 15:03 in Propeller 1
I wrote a short program to allow people to change a line like this:

] DIRA = #0005

into a MOV command

It uses python - so the code should be sorta readable by spinners. If you would like to use it install python, and then replace your MOV commands with a prefix "]" and then use any symbols or registers you'd like.

Let me know what you think. I'm going to improve on it when I can to make loops easier to read and write.

import sys
import os
# file to help people write prop assembly.
# I call it PROP - hELper or propel
# 2007 - Matthew Karas
# Creative Commons Licence
# This work is licensed under a 
#Creative Commons Attribution 3.0 License
#"http://creativecommons.org/licenses/by/3.0/"
#Some Rights Reserved
input = sys.argv
registers = [noparse][[/noparse]'DIRA','DIRB','INA','INB','OUTA','OUTB','CNT',\
        'CTRA','CTRB','FRQA','FRQB','PHSA','PHSB','VCFG',\
        'VSCL','PAR']
widths = [noparse][[/noparse]'LONG','WORD','BYTE']
symbols = [noparse][[/noparse]]

def propel(line):
    tokline = line.split(' ')
    if (tokline in registers) or (tokline in symbols) \
    and tokline == '=':
        outline = "\tMOV\t"+tokline+","+tokline
    else:
    #error if can't find symbol, register, or  = sign
    #error is making the line a comment
    outline = "'Error" + line
    return outline
def addsymbol(line):
    tokline = line.split(' ')
    try:
    if tokline in widths:
        symbols.append(tokline[noparse][[/noparse]0])
    except:
    pass
#start
datseg = False 
#first pass
for line in open(input, 'r'):

    if 'DAT' in line:
    datseg = True
# add symbols
    if datseg:
    addsymbol(line)
#second pass
for line in open(input, 'r'):
    line = line.strip()
    if not line.startswith(']'):
    print line # ignore non helper lines
    continue
    else:
    line = propel(line)
    print line


Comments

  • LucidGuppyLucidGuppy Posts: 32
    edited 2007-09-07 03:10
    for some reason the indents aren't showing up properly.
  • mparkmpark Posts: 1,305
    edited 2007-09-07 15:03
    Very interesting. Will you be making the obvious extensions? E.g.:
    ] x += 1 ' add
    ] x -= 1 ' sub
    ] x &= 1 ' and
    etc., etc.
    Does your code handle if_z, if_c, etc. and wc, wz, nr?
    I always liked alternative assembly languages. I'll be interested to see what you come up with for loops.
Sign In or Register to comment.