On Wed, Aug 12, 2009 at 6:57 PM, david feldman <[email protected]> wrote:

>
>        .arch msp430x1232
>        #include
>        .org    0xE080
>        .text
> main:   mov     #message, R14
>        jmp  main
> message: .ascii "hello world"
>        .byte 0
>        .end
>
....

>
> My source code is the file "f.s" and it is being compiled with the command
> "msp430-gcc -c f.s -o f.out
> ", then converted to intel hex using "msp430-objcopy -O ihex f.out f.hex"
>

You are compiling an object module and converting it to hex, but you fail to
link it.
The object module contains a relocation entry for the site where you refer
to your message:

> msp430-objdump -rd f.out

test:     file format elf32-msp430
Disassembly of section .text:
00000000 <main-0xe080>:
    ...
0000e080 <main>:
    e080:    3e 40 00 00     mov    #0,    r14    ;#0x0000
            e082: R_MSP430_16_BYTE    .text+0xe086
    e084:    fd 3f           jmp    $-4          ;abs 0xe080

0000e086 <message>:
    e086:    68 65           .........................

so you need to let the linker apply this relocation. If you insist on using
raw assembly, I think you would be better off using as and ld explicitly,
not relying on gcc driver to do it for you because gcc uses its own
conventions/memory maps/linker scripts:

msp430-as f.s -o f.out
msp430-ld  f.out -o f.exe

except that it doesn't work because when you specify .org, the toolchain
still includes the bytes from 0000 to e080 in the object. If you delete the
.org directive you can get the linked executable with the correct relocation
applied, but not at your desired address---it uses the linker default fc00.
If you insist on e080, you probably have to write a linker script to remap
your code.

I am not using explicit assembler so I can't help you with that---as others
have advised, it's easier to let the toolchain take care of housekeeping and
use the inline assembler for your code.

Reply via email to