当然首先安装ca850,把ca850的二进制文件地址加入到环境变量PATH中。比如我的需要加入C:\Program Files\NEC Electronics Tools\CA850\V3.42到PATH。然后创建一个目录,比如proj,proj下面创建一个source目录,所有的源代码直接放到source下。然后在proj中新建一个makefile,makefile的内容如下面的代码。然后在命令行运行make即可生成out文件和hex文件。
makefile命令如下,根据实际情况可能需要一些修改:
- V850_COMPILER_PATH="C:\Program Files\NEC Electronics Tools\CA850\V3.42"
- OBJS_DIR=objs
- SOURCE_DIR=source
- CC=ca850
- AS=as850
- LD=ld850
- HX=hx850
- ROM=romp850
- CFLAGS=-DM11_DVD_MODEL_IS
- CFLAGS+=@$(SOURCE_DIR)/compile.cmd
- CFLAGS+=-I$(SOURCE_DIR)
- #cpu ID
- NEC_V850_CPU=f3366
- SFLAGS=-cpu $(NEC_V850_CPU)
- LDFLAGS=-D $(SOURCE_DIR)\link.dir @$(SOURCE_DIR)\link.cmd
- #register mode
- NEC_V850_REGS=r32
- vpath %.c $(SOURCE_DIR)
- vpath %.s $(SOURCE_DIR)
- #libs add additional files
- V850_LINKER_ADDITIONAL_FILE=$(V850_COMPILER_PATH)\lib850\$(NEC_V850_REGS)\rompcrt.o
- V850_LINKER_ADDITIONAL_LIBS=$(V850_COMPILER_PATH)\lib850\$(NEC_V850_REGS)msk\libc.a
- V850_LINKER_ADDITIONAL_LIBS+=$(V850_COMPILER_PATH)\lib850\$(NEC_V850_REGS)\libr.a
- #object name
- TARG=d2osd.out
- HEX_FILE=d2osd.hex
- ELF_FILE=d2osd.elf
- MAP_FILE=d2osd.map
- #all c source code
- C_SRCS = $(wildcard $(SOURCE_DIR)/*.c)
- C_OBJS = $(patsubst %c, %o, $(C_SRCS))
- C_OBJN = $(notdir $(C_OBJS))
- OBJS = $(addprefix $(OBJS_DIR)/, $(C_OBJN))
- #all asm source code
- ASM_SRCS = $(wildcard $(SOURCE_DIR)/*.s)
- ASM_OBJ1 = $(patsubst %s, %o, $(ASM_SRCS))
- ASM_OBJ2 = $(notdir $(ASM_OBJ1))
- ASM_OBJS = $(addprefix $(OBJS_DIR)/, $(ASM_OBJ2))
- $(OBJS_DIR)/%.o: %.c | $(OBJS_DIR)
- $(CC) $(CFLAGS) -o $(OBJS_DIR)/$*.o $<
- $(OBJS_DIR)/%.o: %.s | $(OBJS_DIR)
- $(AS) $(SFLAGS) -o $(OBJS_DIR)/$*.o $<
- all : $(TARG)
- $(TARG): $(OBJS) $(ASM_OBJS)
- $(LD) $(LDFLAGS) -o $(TARG) \
- -m=$(MAP_FILE) \
- $(OBJS) \
- $(ASM_OBJS) \
- $(V850_LINKER_ADDITIONAL_LIBS) \
- $(V850_LINKER_ADDITIONAL_FILE)
- $(ROM) -o $(ELF_FILE) $(TARG)
- $(HX) -o $(HEX_FILE) $(ELF_FILE)
- $(OBJS_DIR):
- mkdir $(OBJS_DIR)
- clean:
- del $(TARG) $(HEX_FILE) $(ELF_FILE) $(MAP_FILE) /Q
- rmdir $(OBJS_DIR) /S /Q
阅读(4304) | 评论(0) | 转发(0) |