Salut ! Avec un nom comme ça, je pense que tu parles français ! 

Assembler file in C project


// *** test.c ***
/* you should declare your assembler function in your C file */
extern void _Init_System(void);

int main(void)
{
/* You can call the function like this */
_Init_System();

while(1)
  {
  /* Xor bit0 of P1 */
  P1OUT^=0x01;
  }
}
// *** end of test.c ***



// *** system.asm ***
; "hardware.h" is your IO, System definition (for the minimal test you create 
an empty file) 
#include "hardware.h"


// declaration of your function (visible for the linker process)
    .global _Init_System
    .text
;-----------------------------------------------------------------------------
; ENTREE : Rien
; SORTIE : Registres systemes
; MODIF :
;-----------------------------------------------------------------------------
_Init_System:
; init P1
    mov.b #0x01,&P1DIR
    mov.b #0x00,&P1SEL
    mov.b #0x00,&P1OUT
    mov.b #0x00,&P1IFG 
    mov.b #0x00,&P1IE 
    ret
// *** end of system.asm***



// *** makefile ***
.SUFFIXES: # Delete the default suffixes

NAME=aout.elf

CC=msp430-gcc
CPU=msp430x123 
DUMP=msp430-objdump
ASMOPT = -mmcu=${CPU}
CFLAGS = -mmcu=${CPU} -O1 -ffixed-r4 -ffixed-r5
LDFLAGS = -mmcu=$(MCU) -Wl,-Map=$(NAME).map --cref

OBJECTS = test.o system.o 

all: ${NAME}

%.o: %.c hardware.h
$(CC) ${CFLAGS} -c $<
$(DUMP) -DS $@ > $<.lst

%.o: %.asm hardware.h
$(CC) -x assembler-with-cpp ${ASMOPT} -D_GNU_ASSEMBLER_ -o $@ -c $<

${NAME}: ${OBJECTS}
$(CC) -mmcu=${CPU} $(LDFLAGS) -o $@ $^
$(DUMP) -DS aout.elf > aout.lst
msp430-objcopy -O ihex $@ [email protected]

.PHONY: clean
clean:
rm -f ${NAME} ${NAME}.hex ${OBJECTS}

// *** end of makefile ***


This is a minimal project ! I advise you to download examples projects here :
    http://cvs.sourceforge.net/viewcvs.py/mspgcc/examples/

you can modify some examples for your tests.
What is your application ?

Me, I use MSP430F427 for instrumentation devices.

A+

  ----- Original Message ----- 
  From: Frederic Beaulieu 
  To: [email protected] 
  Sent: Wednesday, August 24, 2005 3:02 PM
  Subject: RE: [Mspgcc-users] Assembler file organisation


  Is there someone who know how to call an assembler function define in a .S 
file from a C program?

   

  --------------------------------------------
  Frederic Beaulieu, M.Sc.
  Research and Development
  NewTrax Technologies Inc.
  http://www.newtraxtech.com/

  -----Original Message-----
  From: [email protected] 
[mailto:[email protected]] On Behalf Of Frederic Beaulieu
  Sent: Tuesday, August 23, 2005 11:43 AM
  To: MSP430 mspgcc Groups
  Subject: [Mspgcc-users] Assembler file organisation

   

  Hi all,

  I want to do my next project using only assembly to learn a little bit more 
about this language. I never use it before.

  I wonder if someone can explain to me how to manage a large project (how you 
manage your file .s .S .h, how you

  separate your function in these files, how you organize your comments, etc). 
The example from TI are to basic to learn

  from these (too small). May be you can send me one of your old (even very old 
;)) project.

  Thanks in advance!

  Fred

   


Reply via email to