51的startup.asm的问题

2011年04月11日 17:02    发布者:@︻$▅▆▇◤
自己写的startup.ASM文件为什么在有了main.c文件之后会失效?取消main.c就又正常了?

;===================================================================================
#define __ASM_CODE__

#include "compile_option.h"


#include "DC_FSB.h"

;#include "variables.inc"


#define SP_START 07h
#define Ram_Start 08h
#define Ram_End 03Fh


NAME SEGMENT_CODE_START_UP ; Specify the name of the current module
USING 0 ; use register bank 0
;===================================================================================
; Constants
;===================================================================================

;===================================================================================
; Variables
;===================================================================================
;#define BF_CHIP_MODE 2fh.3 ; 0 => chip, 1 => DEEMAX emulator (DC6688FSA/DC6688FS Family, Refer AppNote008)

;===================================================================================
; External reference
;===================================================================================
EXTRN CODE (MAIN)
;EXTRN CODE (Delay_100ms)
CSEG AT 0000H ; code segment start at 0000H
USING 0 ; use register bank 0
;--------------------------------------
; Reset Vector 000h :
;--------------------------------------
ORG 0h
ljmp START_UP



;--------------------------------------
; user program is started here
;compile_option.h
;--------------------------------------

ORG 80h
public START_UP
START_UP:
#ifdef __DEBUG_MODE__
mov 0A0h, #0
#endif


;---------------------------------------------------
; select band 0 registers
;---------------------------------------------------
clr RS0
clr RS1

; ---------------------------------------------------
; OFF_ LED 1st
; ---------------------------------------------------
; lcall Delay_100ms
MOV R0, #xPCCONL ;00 10 00 11
MOV A, #00100011B ;PCCONL 11 = counter A output
MOVX @R0,A ;10 push pull O/P (PC1)
;00 input interrupt on falling edge (PC2, PC0)
MOV R0, #xPORT_C
MOV A, #00000000B ;0x00
MOVX @R0,A

;---------------------------------------------------
; clear DPS_0 to make use of DPTR
;---------------------------------------------------
; mEnable_DPTR_0 ;DPS

;;---------------------------------------------------
;; disable all interrupt and clear all IRQ
;;---------------------------------------------------
mov IE, #0
; disable counter A interrupt
mov TCON, #0 ; clear Port A, Counter A, Timer 0, Timer 1 IRQ
mov T2CON, #0 ; clear Timer 2 IRQ and reset timer config
mov SCON0, #0 ; clear Serial 0 IRQ and reset serial control 0 config
mov SCON1, #0 ; clear Serial 1 IRQ and reset serial control 1 config
mov IP, #0 ; all interupt in low priority

;---------------------------------------------------
; Start + test
;---------------------------------------------------
MOV A,#0 ; MATTHEW
SETB ET2 ; Timer 2 overflow interrupt
CLR IT0 ; falling edge trigger
; SETB EA
CLR EX0

;;---------------------------------------------------
;; disable watchdog
;;---------------------------------------------------
MOV R0, #xBTCON
MOV A, #0xA8
MOVX @R0,A

;---------------------------------------------------
; clear internal RAM
;
; note :
; - clear all direct accessable RAM from 00h
; - clear indirect RAM up to stack area
;---------------------------------------------------
mov a, #Ram_Start ;08h
mov R0, a

clear_all_int_ram_loop:
mov a, #000h
mov @R0, a
inc R0
cjne R0, #Ram_End ,clear_all_int_ram_loop

init_SP:
;---------------------------------------------------
; init Stack pointer
; note :
; - pre-incremented stack
; - because of software stack, it is better to
; init Stack pointer after clear RAM
;---------------------------------------------------
;mov SP, #(LOW (RI_STACK-1)) ; '-1' because of pre-increment
mov SP, #SP_START ;

;all interrupts in low priority
mov IP, #0

;clear IT0 for proper Port A interrupt function
clr IT0

MOV R0, #xPCCONL ;00 10 00 11
MOV A, #00100011B ;PCCONL 11 = counter A output
MOVX @R0,A ;10 push pull O/P (PC1)
;00 input interrupt on falling edge (PC2, PC0)

MOV R0, #xPORT_C ; PC = INPUT MODE, INTERRUPT ON RISING
MOV A, #00000000B ; 0x00 ; PC = push pull output (IR)
MOVX @R0,A ; PC = push pull output (LED)

CLR EX0
; sjmp $

ljmp main

; =====================================================
; =====================================================
; =====================================================
/*
ISR_PORT_BC:
;ISR_PORT_A:
CLR GF_SLEEP0

MOV R0,#xPAPND
MOV A,#0
MOVX @R0,A

; MOV R0,#xPCPND
; MOV A,#0
; MOVX @R0,A

; CLR IE0 ;CLR PORTB, C INTERRUPT FLAG

CLR EX0 ;PortB, C ext interrupt
CLR IT0
NOP
RETI
*/
; =====================================================
; =====================================================
; =====================================================
/*
ISR_TIMER_2:
CLR TF2
RETI
*/
; =====================================================
; =====================================================

#undef __ASM_CODE__
end

网友评论

@︻$▅▆▇◤ 2011年04月11日
前面我;===================================================================================
; External reference
;===================================================================================
EXTRN CODE (MAIN)
EXTRN CODE (Delay_100ms)
CSEG AT 0000H ; code segment start at 0000H
USING 0
后面就可以跳转ljmp main

前面已经用EXTRN CODE (MAIN) 进来了,
后面我直接跳转去ljmp main

我在工程里面去掉main.c,那么这个start文件就能用。如果我一加上main.c的话,它就直接跳到main里面去了,不会经过这个start程序

现在就是这个问题