gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] A success with a stand-alone application on the Raspberry, PI


From: JD
Subject: Re: [Gm2] A success with a stand-alone application on the Raspberry, PI - after modifying the assembler (Gaius Mulley)
Date: Tue, 11 Nov 2014 21:22:10 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 10/11/14 17:00, address@hidden wrote:

Hi John,

thanks for the email - very interesting!  I think you might be able to
achieve this by adding inline assembler into the Modula-2 source code.
So for example:

    MODULE BakingPi2;
    
    VAR GPIOcontrol[20200000H]: ARRAY [0..5] OF BITSET;
    GPIOon[2020001CH]: ARRAY [0..1] OF BITSET;
    GPIOoff[20200028H]: ARRAY [0..1] OF BITSET;
    
    VAR i: CARDINAL;
    
    BEGIN
       ASM VOLATILE ("LDR sp, =stack_top") ;

       GPIOcontrol[1]:= {18};
    
       LOOP (* forever *)
    
       GPIOon[0]:= {16};
       FOR i :=1 TO 100000000 DO (* nothing *)END;
    
       GPIOoff[0]:= {16};
       FOR i :=1 TO 100000000 DO (* nothing *)END;
       END; (* loop *)

       ASM VOLATILE ("STACK: . = . + 0x1000")  (* 4kB of stack memory *)
       ASM VOLATILE ("stack_top = .")

    END BakingPi2.

hope this helps,

regards,
Gaius


------------------------------

Gaius,
That idea doesn't work, at least not straight off.

The first ASM gets put in too late.  I get:
#APP
@ 12 "BakingPi2.mod" 1
    LDR sp, =stack_top
@ 0 "" 2
but this is part way through the code for the main module init (i.e. some way after _M2_BakingPi2_init:).  The final two ASMs do not appear at all.

Also I've moved on to having two modules separately compiled.  The only way I have found to get them to link properly is to use -fm2-whole-program.  As a consequence of this I get init sections for many run-time support      modules (e.g. SYSTEM, RTS, RTExceptions) in the assembler, none of which I need at the moment, and as a result of these I can't seem to get the stack definition and use of it close enough together for the ARM instruction set to cope.  That's probably fixable but I don't know the ARM architecture well enough to do it.

Any thoughts on these issues?
Regards,
John

reply via email to

[Prev in Thread] Current Thread [Next in Thread]