Looks interesting.
On Feb 25, 9:59 am, "Sylvain Munaut <Some...@SomeDomain.com>"
<246...@gmail.com> wrote:
> Hi,
>
> I wasn't very satisfied with the available assembler, so a few month
> ago I wrote a new compiler for the Picobaze during my spare
> weekends ...
>
> I just though I'd share it if anyone is interested ....
>
> It's available there :
> http://www.246tnt.com/files/PBAsm_20080225.tar.bz2
>
> Example usage:
> python ./Codegen.py example.S out.mem
>
> WARNING: The last file on the command line is the output ... so if you
> forget it, it will overwrite your last source file ...
This may seem like a minor annoyance to you, but it is one of those
things that a user will tire of very quickly... after about one lost
file in fact.
Couldn't you fix that so the output file is first or use option flags
to indicate the output file such as -o name?
Reply by Sylvain Munaut●February 29, 20082008-02-29
> >store s0, (sp)0
> >store s1, (sp)1
> >store s2, (sp)2
> >store s3, (sp)3
> >add sp, 4
>
> >Seems kinda hard ...
>
> I don't know the picoblaze procedure/interrupt conventions, but getting
> an interrupt between store s1 & store s2 or so looks like trouble.
There is no convention ... you just fix what you want for yourself.
But indeed, with a classic one, this would be a problem. Solution is
to either
- Don't use interrupts :)
That actually my case for the sw where this snippet comes from
- Make it a critical zone :
cli
store s0, (sp)0
store s1, (sp)1
store s2, (sp)2
store s3, (sp)3
add sp, 4
sti
- Use dual pointer :
add sp, 4
sub bp, sp, 4
store s0, (bp)0
store s1, (bp)1
store s2, (bp)2
store s3, (bp)3
- Have the interrupts with their own dedicated stack and a dedicated
reg used only by them.
So the interrupt handler would start by
.equ si, s14
.bss
__isr_stack: .space 32
.text
__isr:
load si, __isr_stack
store sp, (si)
load sp, si
add sp, 1
store s0, sp(0)
...
...
- Reserve the space 'before' :
add sp, 4
store s0, sp(-4)
store s1, sp(-3)
store s2, sp(-2)
store s3, sp(-1)
Unfortunatly, I don't think my hw mod can extend to allow negative
offset without adding some slices ... I'd have to recheck.
Sylvain
Reply by Gerhard Hoffmann●February 28, 20082008-02-28
On Wed, 27 Feb 2008 12:42:12 -0800 (PST), "Sylvain Munaut <SomeOne@SomeDomain.com>" <246tnt@gmail.com> wrote:
> making a macro that would expand :
>
>STACK_PUSH(s0, s1, s2, s3)
>
>into
>
>store s0, (sp)0
>store s1, (sp)1
>store s2, (sp)2
>store s3, (sp)3
>add sp, 4
>
>Seems kinda hard ...
I don't know the picoblaze procedure/interrupt conventions, but getting
an interrupt between store s1 & store s2 or so looks like trouble.
regards, Gerhard
Reply by Sylvain Munaut●February 28, 20082008-02-28
> You mean something like this -
>
> #define STACK_PUSH(a,b,c,d)
> store a, (sp)0
> store b, (sp)1
> store c, (sp)2
> store d, (sp)3
> add sp, 4
>
> STACK_PUSH(s0, s1, s2, s3)
:) I meant with a variable number of argument, autoadapting itself.
Sylvain
Reply by Mark●February 28, 20082008-02-28
Sylvain Munaut <SomeOne@SomeDomain.com> wrote:
> On Feb 27, 9:15 pm, n...@puntnl.niks (Nico Coesel) wrote:
>> "Sylvain Munaut <Some...@SomeDomain.com>" <246...@gmail.com> wrote:
>>
>>
>>
>>> I'm not that interested in HLL because when I uses theses. But a macro
>>> preprocessor would be nice :)
>> You can use plain old cpp for that purpose. A few months ago I wrote a
>> PLC compiler thingy. I used cpp as a preprocessor for it.
>
> Mmm, I hadn't tought of that.
> That's a nice easy way to get a well known syntax.
>
> However for an assembler it's nice to have more 'advanced' things. I'm
> not an expert in the C preprocessor but making a macro that would
> expand :
>
> STACK_PUSH(s0, s1, s2, s3)
>
> into
>
> store s0, (sp)0
> store s1, (sp)1
> store s2, (sp)2
> store s3, (sp)3
> add sp, 4
>
> Seems kinda hard ...
You mean something like this -
#define STACK_PUSH(a,b,c,d)
store a, (sp)0
store b, (sp)1
store c, (sp)2
store d, (sp)3
add sp, 4
STACK_PUSH(s0, s1, s2, s3)
Mark
>On Feb 27, 9:15 pm, n...@puntnl.niks (Nico Coesel) wrote:
>> "Sylvain Munaut <Some...@SomeDomain.com>" <246...@gmail.com> wrote:
>>
>>
>>
>> >I'm not that interested in HLL because when I uses theses. But a macro
>> >preprocessor would be nice :)
>>
>> You can use plain old cpp for that purpose. A few months ago I wrote a
>> PLC compiler thingy. I used cpp as a preprocessor for it.
>
>Mmm, I hadn't tought of that.
>That's a nice easy way to get a well known syntax.
>
>However for an assembler it's nice to have more 'advanced' things. I'm
>not an expert in the C preprocessor but making a macro that would
>expand :
>
>STACK_PUSH(s0, s1, s2, s3)
>
>into
>
>store s0, (sp)0
>store s1, (sp)1
>store s2, (sp)2
>store s3, (sp)3
>add sp, 4
>
>Seems kinda hard ...
You shouldn't push the limits too far... Your example smells more like
assembler extensions than macro's.
--
Programmeren in Almere?
E-mail naar nico@nctdevpuntnl (punt=.)
Reply by Sylvain Munaut●February 27, 20082008-02-27
On Feb 27, 9:15 pm, n...@puntnl.niks (Nico Coesel) wrote:
> "Sylvain Munaut <Some...@SomeDomain.com>" <246...@gmail.com> wrote:
>
>
>
> >I'm not that interested in HLL because when I uses theses. But a macro
> >preprocessor would be nice :)
>
> You can use plain old cpp for that purpose. A few months ago I wrote a
> PLC compiler thingy. I used cpp as a preprocessor for it.
Mmm, I hadn't tought of that.
That's a nice easy way to get a well known syntax.
However for an assembler it's nice to have more 'advanced' things. I'm
not an expert in the C preprocessor but making a macro that would
expand :
STACK_PUSH(s0, s1, s2, s3)
into
store s0, (sp)0
store s1, (sp)1
store s2, (sp)2
store s3, (sp)3
add sp, 4
Seems kinda hard ...
Sylvain
>
>I'm not that interested in HLL because when I uses theses. But a macro
>preprocessor would be nice :)
You can use plain old cpp for that purpose. A few months ago I wrote a
PLC compiler thingy. I used cpp as a preprocessor for it.
--
Programmeren in Almere?
E-mail naar nico@nctdevpuntnl (punt=.)
Reply by Sylvain Munaut●February 27, 20082008-02-27
On Feb 26, 9:47 am, Andrew Greensted <ajg...@ohm.york.ac.uk> wrote:
> Sylvain Munaut <Some...@SomeDomain.com> wrote:
> > Hi,
>
> > I wasn't very satisfied with the available assembler, so a few month
> > ago I wrote a new compiler for the Picobaze during my spare
> > weekends ...
>
> Hi Sylvain,
>
> Nothing to add but encouragement really. The software offerings for
> picoblaze are limited, especially in the non-windows world. Both picoasm
> and kpicosim are very good, but their development seems to have stopped.
Yes they did a great job and I used those for a some time.
But since they respected the Xilinx 'standard' assembly format, they
were limited ...
I choose to break compatibility so that I could extend easily. But
even without the compatibility, it's pretty easy to convert old
software.
Mostly a few subsitute with regexp and adding a .text at the start and
that should do it :)
> If you can get a polished version of your assembler finished, it sounds
> like it would be a great tool.
Thanks.
I'll try to polish things up a little and maybe write some
documentation and so forth.
But I probably won't do a lot of work on it since I changed job and
this new one is not related to fpga (nor hw dev) in any way ...
Sylvain
Reply by Sylvain Munaut●February 27, 20082008-02-27
> Of course, you're working on the simulator now, right? :)
I don't think so ... I rarely used the one that are available because
the code on the picoblaze is often so dependent on the hw around it
that it just doesn't do anything meaning full without it ...
What I did is that my assembler output a symbol table and so in the
modelsim you can get it to display :
uart_print_str + 0x00, uart_print_str + 0x01 .... instead of the
addesses in the code, and also the variable name instead of address in
the scratch pad. Very useful to trace what's going on.
Sylvain