qasm - A P2 Assembler written in C

Dave HeinDave Hein Posts: 6,139
edited 2015-12-04 - 19:46:34 in Propeller 2
Qasm is a C program that assembles P2 code. I've verified it against the PNUT binaries, and it matches except for some slight differences in floating point constants. I wrote qasm a few years ago so I could write P2 code before PNUT was available. However, even though PNUT is available there are times that I like to run things from the command line. So I brought qasm up to date with the latest P2 instruction definitions. It also generates a list file that might be useful. The list file for all_cogs_blinks looks like this:
                   dat
00000              		orgh	0
                   '
                   ' launch cogs 15..0 with blink program
                   ' cogs that don't exist won't blink
                   '
00000 000          		org
                   
00000 000 fce4040c .loop		coginit	cognum,#@blink
00004 001 f9dc05fe 		djns	cognum,#.loop
                   
00008 002 0000000f cognum		long	15
                   '
                   ' blink
                   '
0000c 000          		org
                   
0000c 000 fd600e01 blink		cogid	x		'which cog am I?
00010 001 f463f607 		setb	dirb,x		'make that pin an output
00014 002 f423fa07 		notb	outb,x		'flip its output state
00018 003 f1040e10 		add	x,#16		'add to my id
0001c 004 f0640e12 		shl	x,#18		'shift up to make it big
00020 005 fd600e28 		waitx	x		'wait that many clocks
00024 006 fd9fffe4 		jmp	#blink		'do it again
                   
00028 007          x		res	1
I included a Windows executable in the zip file. Executables for other platforms can be built from source by running the "buildit" script file.

Comments

  • Cool!!!

    All we need is a loader source that works and we can have testers that can't use Windows play along!

    Thanks, Dave!!
  • jmgjmg Posts: 14,477
    That's cool.
    Does it support macros and conditional assemble ?
    It could follow the gas format for those directives, for portability.

    I found some here
    http://cs.mtu.edu/~mmkoksal/blog/?x=entry:entry120116-130037
  • @mindrobots, yes I had people in mind that can't use Windows, or won't use it (Hi, Heater :) ). When used along with spinsim you can write P2 code, assemble it and then run it under spinsim on any platform.

    @jmg, there are no macros or conditional assembly. It just converts opcodes to binary. I am thinking of adding the capability to produce object files that can be linked together by a linker. However, I'm not planning on adhering to any Gnu standards.
  • jmgjmg Posts: 14,477
    Dave Hein wrote: »
    @jmg, there are no macros or conditional assembly. It just converts opcodes to binary. I am thinking of adding the capability to produce object files that can be linked together by a linker. However, I'm not planning on adhering to any Gnu standards.

    Interesting - do you have linking with something else in mind ?
  • I'd like to be able to create a library and then link to it to build a program.
  • This is pretty nice Dave. :)

  • can't use Windows, or won't use it (Hi, Heater )

    Hi Dave, I heard that. This is cool, thanks for thinking of us rebels.

    Does this understand all the syntax of Spin style VAR and DAT sections that PASM may need to use?
  • It doesn't support VAR sections. It should handle the syntax correctly in DAT and CON sections. The only issue I know at this point is that constants must be defined before any lines that reference them.
  • mindrobots wrote: »
    Cool!!!

    All we need is a loader source that works and we can have testers that can't use Windows play along!

    I'll mulling over my options right now. PNut.exe is the only loader I presume? Anyone know otherwise?

    I was thinking there might be detailed protocol info in the pasm files in Chip's updates but I haven't looked as yet ... must get back to work ....
  • We had P2load on the "hot" chip, but that was a bit farther along in the process.

    Peter and Chip were discussing SPI / SD card. If that happens, there is a path for something other than Pnut.

  • I have been working quietly on shrinking Kye's FAT driver, currently for the P1. Once it's done I can convert it to P2.
  • @Cluso99

    re:I have been working quietly on shrinking Kye's FAT driver, currently for the P1. Once it's done I can convert it to P2.

    Great! I just started to work on a project that will use PROP 1 FAT and PROP 2 FAT later. if you need a tester later just let me know.
Sign In or Register to comment.