查看: 3362|回复: 1

[提问] 51的startup.asm的问题

[复制链接]
发表于 2011-4-11 17:02:48 | 显示全部楼层 |阅读模式
自己写的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[1,0] 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[1,0] 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[2] = INPUT MODE, INTERRUPT ON RISING
MOV A, #00000000B ; 0x00 ; PC[1] = push pull output (IR)
MOVX @R0,A ; PC[0] = 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-4-11 17:03:14 | 显示全部楼层
前面我;===================================================================================
; 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程序

现在就是这个问题
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关于我们  -  服务条款  -  使用指南  -  站点地图  -  友情链接  -  联系我们
电子工程网 © 版权所有   京ICP备16069177号 | 京公网安备11010502021702
快速回复 返回顶部 返回列表