MSP430 - using assembler only (mspgcc)

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hello everyone!

Currently I'm playing a bit around with a MSP430 microcontroller board from
TI, using the mspgcc port of gcc. Everything works fine using the c
compiler, and now I'm trying to get it to work using only the assembler
(msp430-as). I'd like to write an assembler equivilant to the minimal c
program:

int main(void) {
    while(1) {}
    return 0;
}

Looking at the disassembly (msp430-objdump -D a.out) of the above c program,
there's a special .section called ".vectors", that holds a list of interrupt
vectors and the reset vector. This list is always located at 0x0000ffe0.
Now for the problem: I really can't get msp430-as to produce exactly the
same disassembly as the c program. I can't even get it to reconize the
.vectors section as something worth outputing in the objdump.

I've tryed to use the ".org" assembler directive to force placement of the
sections. But that doesn't produce the same results either...

Where should I go from here? Any good documents that explains everything in
a way, a complete newbie like myself, can understand?

Btw, I'm not totally sure this is the right newsgroup to ask this question -
if it isn't, please flame me. :)

--
mvh Rasmus Neckelmann



Re: MSP430 - using assembler only (mspgcc)

the minimal c
Quoted text here. Click to load it
program,

Why don't you simply use the -S option of gcc when compiling? This will give
you a <myprogram>.s file containing input for gas.

/Roland



Re: MSP430 - using assembler only (mspgcc)
Quoted text here. Click to load it

Well... I runs the following commands, where "test.c" is the above program:

msp430-gcc -S -mmcu=msp430x149 test.c
msp430-as test.s -mmcu=msp430x149
msp430-objdump -D a.out

objdump outputs the following:

----- START OF OUTPUT -----
a.out:     file format elf32-msp430

Disassembly of section .text:

00000000 <main>:
   0:   31 40 00 00     mov     #0,     r1      ;#0x0000
   4:   04 41           mov     r1,     r4      ;
   6:   ff 3f           jmp     $+0             ;abs 0x6
   8:   30 40 00 00     br      #0x0000         ;
Disassembly of section .data:
----- END OF OUTPUT -----

When I run msp430-gcc without the -S option and dumps a.out directly after
gcc, it says:

----- START OF OUTPUT ------
Disassembly of section .text:

00001100 <_reset_vector__>:
    1100:       b2 40 80 5a     mov     #23168, &0x0120 ;#0x5a80
    1104:       20 01
    1106:       3f 40 50 11     mov     #4432,  r15     ;#0x1150
    110a:       3e 40 00 02     mov     #512,   r14     ;#0x0200
    110e:       3d 40 00 02     mov     #512,   r13     ;#0x0200
    1112:       0d 9e           cmp     r14,    r13     ;
    1114:       05 24           jz      $+12            ;abs 0x1120
    1116:       fe 4f 00 00     mov.b   @r15+,  0(r14)  ;
    111a:       1e 53           inc     r14             ;
    111c:       0e 9d           cmp     r13,    r14     ;
    111e:       fb 2b           jnc     $-8             ;abs 0x1116
    1120:       3f 40 00 02     mov     #512,   r15     ;#0x0200
    1124:       3d 40 00 02     mov     #512,   r13     ;#0x0200
    1128:       0d 9f           cmp     r15,    r13     ;
    112a:       05 24           jz      $+12            ;abs 0x1136
    112c:       cf 43 00 00     mov.b   #0,     0(r15)  ;r3 As=00%
    1130:       1f 53           inc     r15             ;
    1132:       0f 9d           cmp     r13,    r15     ;
    1134:       fb 2b           jnc     $-8             ;abs 0x112c
    1136:       30 40 40 11     br      #0x1140         ;

0000113a <vector_ffe0>:
    113a:       30 40 3e 11     br      #0x113e         ;

0000113e <_unexpected_>:
    113e:       00 13           reti

00001140 <main>:
    1140:       31 40 00 0a     mov     #2560,  r1      ;#0x0a00
    1144:       04 41           mov     r1,     r4      ;
    1146:       ff 3f           jmp     $+0             ;abs 0x1146
    1148:       30 40 4c 11     br      #0x114c         ;

0000114c <__stop_progExec__>:
    114c:       02 df           bis     r15,    r2      ;
    114e:       fe 3f           jmp     $-2             ;abs 0x114c
Disassembly of section .data:
Disassembly of section .vectors:

0000ffe0 <InterruptVectors>:
    ffe0:       3a 11           interrupt service routine at 0x113a
    ffe2:       3a 11           interrupt service routine at 0x113a
    ffe4:       3a 11           interrupt service routine at 0x113a
    ffe6:       3a 11           interrupt service routine at 0x113a
    ffe8:       3a 11           interrupt service routine at 0x113a
    ffea:       3a 11           interrupt service routine at 0x113a
    ffec:       3a 11           interrupt service routine at 0x113a
    ffee:       3a 11           interrupt service routine at 0x113a
    fff0:       3a 11           interrupt service routine at 0x113a
    fff2:       3a 11           interrupt service routine at 0x113a
    fff4:       3a 11           interrupt service routine at 0x113a
    fff6:       3a 11           interrupt service routine at 0x113a
    fff8:       3a 11           interrupt service routine at 0x113a
    fffa:       3a 11           interrupt service routine at 0x113a
    fffc:       3a 11           interrupt service routine at 0x113a
    fffe:       00 11           interrupt service routine at 0x1100
----- END OF OUTPUT ------

Not exactly the same, right? I guess I have to give extra instructions to
the linker/assembler, or something. Still kind of lost, sorry.
Anyone?

--
mvh Rasmus Neckelmann



Re: MSP430 - using assembler only (mspgcc)
[...]
Quoted text here. Click to load it


[...]
Quoted text here. Click to load it
[...]

Quoted text here. Click to load it

No, but you *will* have to *run* the linker.  When you dropped the -S
option, you used gcc in its default mode of operation, where it compiles
*and* immediately links the code you give it to a complete executable.

In your manual test with the -S option, you didn't link at all.

You'll find that

    msp430-gcc -S -mmcu=msp430x149 test.c
    msp430-gcc -v -mmcu=msp430x149 test.s

gives you exactly the same output as a direct compilation of test.c.
I put in the '-v' flag so you can watch gcc call the linker after
assembling test.s.

--
Hans-Bernhard Broeker ( snipped-for-privacy@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Re: MSP430 - using assembler only (mspgcc)
Quoted text here. Click to load it

Now it seems to work! :)  Thanks!

--
mvh Rasmus Neckelmann



Re: MSP430 - using assembler only (mspgcc)

Quoted text here. Click to load it
give

If you're using gas, the mantra

 -Wa,ahlms=myfile.lst

added to the GCC command line produces an assembly listing to myfile.lst, in
addition to the other outputs.

Tauno Voipio
tauno voipio @ iki fi



Re: MSP430 - using assembler only (mspgcc)
Quoted text here. Click to load it

"msp430-gcc -mmcu=msp430x149 -Wa,ahlms=myfile.lst test.c"  produces the
following output:

---- START OF OUTPUT ----
Assembler messages:
Error: can't open ahlms=myfile.lst for reading
ahlms=myfile.lst: No error
----- END OF OUTPUT ----

Isn't "gas" and "as" the same thing? Or am I wrong?

--
mvh Rasmus Neckelmann




Re: MSP430 - using assembler only (mspgcc)
Quoted text here. Click to load it


Sorry, mea culpa...

   -Wa,-ahlms=myfile.lst

Note the minus after the comma. Please note also that there may be no spaces
in the mantra.

HTH

Tauno Voipio
tauno voipio @ iki.fi




Site Timeline