Several problems.  SP is apparently not a register name; use r1.  msp430-gas
does not recognize non-decimal numbers using a suffix letter; use 0x41 for
01000001b  and 41h.  (All those #01000001b values are being recognized as
backwards jumps to a label denoted by an octal number.)

Some of that may or may not be considered a bug.  For example, if you think
msp430-gas should support radix suffixes, please file a tracker ticket.

 If you want to replace the main routine but still link with the C runtime
support, you should put it in section .init9 not in text.  Use "msp430-gcc
-S foo.c" on a trivial main routine to see what directives are expected.

Similarly, compile some sample programs that use attribute((interrupt(V)))
to see what's expected when defining an interrupt vector.

If you don't have any need to link with the C runtime support (it is truly
an asm-only program), use msp430-as instead of msp430-gcc.  It may still be
relevant which section you put things in (it will be, for vectors), but
without linking in crt0.a at least the remaining init/fini sections should
be empty and text will start at the beginning of flash.  Look at the
msp430.x scripts coming from binutils to see the relevant section order.

Peter


On Sun, Oct 2, 2011 at 1:08 PM, Jasper Lievisse Adriaanse
<jas...@humppa.nl>wrote:

> Hi,
>
> Whilst trying to do some assembly-only coding I ran into an (probably
> PEBKAC)
> issue. I have this simple file called foo.S:
>
> -----8<-----
> #include <msp430.h>
>
>
> ;------------------------------------------------------------------------------
> ;   Main Code
>
> ;------------------------------------------------------------------------------
>
>            .text                           ; program start
>            .global _main                   ; define entry point
>
> _main:       mov.w   #0280h,SP               ; initialize stack pointer
>            mov.w   #WDTPW|WDTHOLD,&WDTCTL  ; stop watchdog timer
>
>            bis.b   #01000001b,&P1DIR       ; make P1.0 and P1.6 output
>                                            ; all others are inputs by
> default
>
> Mainloop:    bit.b   #00001000b,&P1IN        ; read switch at P1.3
>            jc      Off                     ; if P1.3 open branch to Off
> label
>
> On:          bic.b   #00000001b,&P1OUT       ; clear P1.0 (red off)
>            bis.b   #01000000b,&P1OUT       ; set P1.6 (green on)
>            jmp     Wait                    ; branch to a delay routine
>
> Off:         bis.b   #00000001b,&P1OUT       ; set P1.0 (red on)
>            bic.b   #01000000b,&P1OUT       ; clear P1.6 (green off)
>
> Wait:        mov.w   #1834,R15               ; load R15 with value for
> delay
> L1:          dec.w   R15                     ; decrement R15
>            jnz     L1                      ; if R15 is not zero jump to L1
>            jmp     Mainloop                ; jump to the Mainloop label
>
>
> ;------------------------------------------------------------------------------
> ;   Interrupt Vectors
>
> ;------------------------------------------------------------------------------
>            .sect   ".reset"                ; MSP430 RESET Vector
>            .short  _main
>
>            .end
> -----8<-----
>
> Afaics this code is correct, though gcc disagrees:
> $ msp430-gcc -g -Os -mmcu=msp430g2213 cstack.S -o cstack.o
> cstack.S: Assembler messages:
> cstack.S:13: Error: backward ref to unknown label "262145:"
> cstack.S:16: Error: backward ref to unknown label "512:"
> cstack.S:19: Error: backward ref to unknown label "1:"
> cstack.S:20: Error: backward ref to unknown label "262144:"
> cstack.S:23: Error: backward ref to unknown label "1:"
> cstack.S:24: Error: backward ref to unknown label "262144:"
> $
>
> Anyone with a cluebat?
>
> Also, is the explicit stack pointer initialization needed with gcc or will
> it
> do this automagically?
>
> --
> Cheers,
> Jasper
>
> "Capable, generous men do not create victims, they nurture them."
>
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2dcopy2
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to