FPGARelated.com
Forums

Picoblaze enhencement and assembler

Started by Sylvain Munaut February 25, 2008
"Sylvain Munaut <SomeOne@SomeDomain.com>" <246tnt@gmail.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 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=.)
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
> 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
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
> >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
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?