📄 start.src
字号:
;
; Unpack two single precision floating point operands
#line 743 "c:\program files\tasking\c166 v8.0\include\head.asm"
; Unpack one double precision floating point operand
#line 748 "c:\program files\tasking\c166 v8.0\include\head.asm"
; Unpack two double precision floating point operands
#line 760 "c:\program files\tasking\c166 v8.0\include\head.asm"
#line 23 "start.asm"
$INCLUDE(_c_init.asm) ; Initialize C variables
#line 1 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
;*****************************************************************************
;*
;* MODULE : _c_init.asm
;*
;* DESCRIPTION : C copy table code for C16x/ST10 microcontroller.
;*
;* - Initialization of static variables in internal or external
;* ram. C variables which have to be initialized are specified
;* in ROM section C166_INIT. C variables which must
;* be cleared are specified in ROM section C166_BSS.
;* - Set user stack pointer.
;*
;* Copyright 1997-2003 Altium BV
;*
;*****************************************************************************
ASSUME DPP3:SYSTEM ; assume system data page pointer.
PUBLIC __C_INIT
; Predefined functions for register R1, R2 and R3.
POF_RAM LIT 'R1' ; Page offset address ram data.
SOF_RAM LIT 'R1' ; Segment offset address ram data.
SOF_RAM_H LIT 'RH1' ; Segment address high byte.
POF_ROM LIT 'R2' ; Page offset address rom data.
SOF_ROM LIT 'R2' ; Segment offset address rom data.
SOF_ROM_H LIT 'RH2' ; Segment address high byte.
BP_RAM LIT 'R3' ; Bit position ram data
;*****************************************************************************
;* __C_INIT
;*****************************************************************************
__C_INIT_PR SECTION CODE PUBLIC 'C_INIT'
#line 39 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
__C_INIT PROC NEAR
#line 44 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
BOTTOM_BITRAM LIT '0FD00H'
#line 55 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
; Clear bit addressable memory
MOV R1, #0FDFEH ; R1 = top of bit addressable area
loop: CMP R1, #CSTART_RBANK + 2 ; if( R1 in bit addressable area )
JMP CC_EQ, cbclr ; then continue next (bit) word clear.
CMP R1, #CSTART_RBANK ; if (R0 in bit addressable area )
JMP CC_EQ, cbclr ; then continue next (bit) word clear.
MOV [R1], ZEROS ; clear
cbclr: CMPD2 R1, # BOTTOM_BITRAM ; if( not bottom bit addressable area )
JMP CC_NE, loop ; then continue next (bit) word clear
; C166_INIT
MOV R4, #POF ?C166_INIT_HEAD ; move intra-page offset address rom
; data section C166_INIT to R4
INIT_DPP0: ;
MOV DPP0,#PAG ?C166_INIT_HEAD ; load data page pointer register DPP0
; with data page of rom data C166_INIT
NOP ; delay for pipeline effect
#line 84 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
INIT: ;
MOV R5, [R4+] ; INIT block header code -> R5
CMP R5, #01H ; check if header code 1 (bit)
JMP CC_EQ, INIT_01 ;
#line 101 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
CMP R5, #06H ; check if header code 6 (far)
JMP CC_EQ, INIT_06 ;
CMP R5, #07H ; check if header code 7 (huge)
JMP CC_NE, INIT_END ; if(no header code) end initialization
INIT_07: ; initialize huge ram data. (data > 64K)
MOV SOF_RAM, [R4+] ; move intra-segment offset address ram
; data block to SOF_RAM=R1
MOV R3, [R4+] ; move segment address ram data block
; to register R3
; process data page number ram data
MOV RH3, SOF_RAM_H ; R3.15, R3.14: low bits of page number (byte forwarding)
ROL R3, #2 ; shift R3.15, R3.14 to R3.1 and R3.0
AND R3, #03FFH ; mask page number
MOV DPP1, R3 ; load data page pointer register DPP1
; with data page of ram data block
BCLR SOF_RAM.15 ; DPP1:POF_RAM ->SOF_RAM
BSET SOF_RAM.14 ;
;
MOV SOF_ROM, [R4+] ; move intra-segment offset address rom
; data block to SOF_ROM=R2
MOV R3, [R4+] ; move segment address rom data block
; to R3
; process data page number rom data
MOV RH3, SOF_ROM_H ; R3.15, R3.14=low bits of page number (byte forwarding)
ROL R3, #2 ; shift R3.15, R3.14 to R3.1 and R3.0
AND R3, #03FFH ; mask page number
MOV DPP2, R3 ; load data page pointer register DPP2
; with data page of rom data block
BSET SOF_ROM.15 ; DPP2:POF_ROM ->SOF_ROM
BCLR SOF_ROM.14 ;
;
MOV R5, [R4+] ; number of bytes (R6:R5) to move from
MOV R6, [R4+] ; rom to ram. MSW=R6, LSW=R5 (long word)
;
MB07_3: ; Service Watchdog Timer (if enabled)
CMPD1 R5, #0 ; test if all bytes are moved and
JMP CC_NE, MB07_1 ; decrement number of bytes to move.
CMPD1 R6, #0 ;
#line 155 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
JMP CC_EQ, INIT ; if( block end ) next initialization
MB07_1: MOVB [SOF_RAM], [SOF_ROM] ; move byte from rom to ram
CMPI1 SOF_RAM, #07FFFH ; test end of data page and inc SOF_RAM
JMP CC_NE, MB07_2 ; if(no page end) cont init current page
MOV SOF_RAM, #04000H ; preset offset address ram data
ADD DPP1, #1 ; next page of ram data; increment DPP1
MB07_2: CMPI1 SOF_ROM, #0BFFFH ; test end of page and inc SOF_ROM
JMP CC_NE, MB07_3 ; if(no page end) cont init current page
MOV SOF_ROM, #08000H ; preset offset address rom data
ADD DPP2, #1 ; next page of rom data; increment DPP2
JMP CC_UC, MB07_3 ; jump for next byte move
#line 175 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
INIT_06: ; initialize far ram data. (CPU mode
; is segmented with DPP usage linear
; or paged.)
MOV POF_RAM, [R4+] ; move intra-page offset address ram
; data block to POF_RAM=R1
BCLR SOF_RAM.15 ; DPP1:POF_RAM ->SOF_RAM
BSET SOF_RAM.14 ;
MOV DPP1, [R4] ; load data page pointer register DPP1
; with data page of ram data block
ADD R4, #2 ; inc offset address to ram data section
; C166_INIT and also insure a delay for
; pipeline effect.(DPP1 set)
;
MOV POF_ROM, [R4+] ; move intra-page offset address rom
; data block to POF_ROM=R2
BSET SOF_ROM.15 ; DPP2:POF_ROM ->SOF_ROM
BCLR SOF_ROM.14 ;
MOV DPP2, [R4] ; load data page pointer register DPP2
; with data page of rom data block
ADD R4, #2 ; inc offset address to rom data section
; C166_INIT and also insure a delay for
; pipeline effect.(DPP2 set)
;
MOV R5, [R4+] ; number of bytes to move from rom to
; ram for specified data block.
;
MB06_1: ; Service Watchdog Timer (if enabled)
CMPD1 R5, #0 ; test on data block end
#line 218 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
JMP CC_EQ, INIT ; if( block end ) next initialization
MOVB [SOF_RAM], [SOF_ROM+] ; move byte from rom to ram, inc SOF_ROM
ADD SOF_RAM, #1 ; inc SOF_RAM
JMP CC_UC, MB06_1 ; jump for next byte move
#line 259 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
#line 370 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
; NO BIT INITIALIZATION
;
INIT_01:
ADD R4,#0CH ; skip DBPTR, DPTR and DW
JMP CC_UC, INIT ; continue with next initialization
INIT_END: ;
; C166_BSS
MOV R4, #POF ?C166_BSS_HEAD ; move intra-page offset address rom
; data section C166_BSS to R4
BSS_DPP0: ;
MOV DPP0,#PAG ?C166_BSS_HEAD ; load data page pointer register DPP0
; with data page of rom data C166_BSS
NOP ; delay for pipeline effect
#line 391 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
BSS: ;
MOV R5, [R4+] ; BSS block header code -> R5
#line 403 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
CMP R5, #06H ; check if header code 6 (far)
JMP CC_EQ, BSS_06 ;
CMP R5, #07H ; check if header code 7 (huge)
JMP CC_NE, BSS_END ; if(no header code) end initialization
BSS_07: ; clear huge ram data (data > 64 K)
MOV SOF_RAM, [R4+] ; move intra-segment offset address ram
; data block to SOF_RAM=R1
MOV R3, [R4+] ; move segment address ram data block
; to R3
; process data page number ram data
MOV RH3, SOF_RAM_H ; R3.15, R3.14=low bits of page number *byte forwarding)
ROL R3, #2 ; shift R3.15, R3.14 to R3.1 and R3.0
AND R3, #03FFH ; mask page number
MOV DPP1, R3 ; load data page pointer register DPP1
; with data page of ram data block
BCLR SOF_RAM.15 ; DPP1:POF_RAM ->SOF_RAM
BSET SOF_RAM.14 ;
;
MOV R5, [R4+] ; number of bytes (R6:R5) to clear in
MOV R6, [R4+] ; specified ram data block.
; MSW=R6, LSW=R5 (long word)
;
CB07_2: ; Service Watchdog Timer (if enabled)
CMPD1 R5, #0 ; test if all bytes are cleared and
JMP CC_NE, CB07_1 ; decrement number of bytes to clear.
;
CMPD1 R6, #0 ;
#line 441 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
JMP CC_EQ, BSS ; if( block end ) next initialization
;
CB07_1: MOVB [SOF_RAM], ZEROS ; clear byte
CMPI1 SOF_RAM, #07FFFH ; test end of data page and inc SOF_RAM
JMP CC_NE, CB07_2 ; if(no page end) next byte clear
;
MOV SOF_RAM, #04000H ; preset offset address ram data
ADD DPP1, #1 ; next page ram data; increment DPP1
JMP CC_UC, CB07_2 ; jump for next byte clear
#line 455 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
BSS_06: ; clear far ram data. (CPU mode is
; segmented with DPP usage linear or
; paged.)
MOV POF_RAM, [R4+] ; move intra-page offset address ram
; data block to POF_RAM=R1
BCLR SOF_RAM.15 ; DPP1:POF_RAM ->SOF_RAM
BSET SOF_RAM.14 ;
MOV DPP1, [R4] ; load data page pointer register DPP1
; with data page of ram data block
ADD R4, #2 ; inc offset address to ram data section
; C166_BSS and also insure a delay for
; pipeline effect. (DPP1 set)
;
MOV R5, [R4+] ; number of bytes to clear in specified
; ram data block
;
CB06_1: ; Service Watchdog Timer (if enabled)
CMPD1 R5, #0 ; test on data block end
#line 478 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
JMP CC_EQ, BSS ; if( block end ) next initialization
MOVB [SOF_RAM], ZEROS ; clear byte
ADD SOF_RAM, #1 ; inc SOF_RAM
JMP CC_UC, CB06_1 ; jump for next byte clear
#line 488 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
#line 521 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
BSS_END:
#line 529 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
MOV DPP0, #0 ; restore DPP0 to its default value
MOV DPP1, #PAG C166_XGROUP ; set DPP1 to page of xnear data/user stack
MOV DPP2, #PAG C166_DGROUP ; set DPP2 to page of default data
; group
#line 538 "c:\program files\tasking\c166 v8.0\include\_c_init.asm"
ret ; return address on the system stack
__C_INIT ENDP
__C_INIT_PR ENDS
#line 24 "start.asm"
NAME CSTART ; module name
PUBLIC __IDLE ; cstart end
PUBLIC __EXIT ; address to jump to on 'exit()'
EXTERN _main:NEAR ; start label user program
EXTERN __C_INIT:NEAR
__CSTART_PR SECTION CODE WORD PUBLIC 'CPROGRAM'
__CSTART PROC TASK __CSTART_TASK INTNO __CSTART_INUM = 0
MOV ADDRSEL1, #0x0406
BFLDL BUSCON1, #0xFF, #0x04AE&0xFF
BFLDH BUSCON1, #0xF6, #(0x04AE>>8)&0xFF
BFLDL SYSCON, #0xFF, #0x0184&0xFF
BFLDH SYSCON, #0xFF, #(0x0184>>8)&0xFF
EXTR #1
MOV XPERCON, #0x000D
#line 344 "c:\program files\tasking\c166 v8.0\include\head.asm"
mov R0, #0x000D
#line 43 "start.asm"
mov XPEREMU, R0 ; initialize XPEREMU
ATOMIC #3
MOV SP, #?SYSSTACK_TOP ; Set stack pointer.
MOV STKOV, #?SYSSTACK_BOTTOM + 6*2 ; Set stack overflow pointer.
MOV STKUN, #?SYSSTACK_TOP ; Set stack underflow pointer.
MOV CP, #CSTART_RBANK ; Set context pointer.
NOP
MOV DPP1, #PAG C166_XGROUP ; set DPP1 to page of user stack / xnear data
MOV R0, #POF (?USRSTACK_TOP - 2) + 0x4002 ; set user stack pointer
DISWDT ; Disable watchdog timer
EINIT ; End of initialization
; disable(0)/enable(1) initialization of bit
; variables at startup
call __C_INIT ; return address pushed on system stack (@Rx not used) ; initalization of global/static data
BSET IEN ; allow monitor to break application
MOV R12, #0 ; set argc to 0
MOV R13, #0 ;
MOV R14, #0 ; set argv[] to 0
call _main ; return address pushed on system stack (@Rx not used)
; The exit() function causes normal program termination to occur. First, all
; functions registered by the atexit() function are called in the reverse
; order. Next, all open streams with unwritten buffered data are flushed, all
; open streams are closed and all files created by the tmpfile() function are
; removed. The status value passed to exit is returned in R4.
__EXIT: LABEL FAR ; the exit() or abort() function jumps
; to this entry.
__IDLE: IDLE ; Power down CPU until peripheral inter-
; rupt or external interrupt occurs.
JMPR CC_UC, __IDLE ; set idle mode again.
RETV ; Virtual return.
__CSTART ENDP
__CSTART_PR ENDS
C166_US SECTION DATA WORD GLBUSRSTACK 'CUSTACK'
DS 2 ; Allocate a user stack of at least 2 bytes
C166_US ENDS
C166_DGROUP DGROUP __DUMMY
__DUMMY SECTION DATA WORD PUBLIC 'CNEAR'
__DUMMY ENDS
C166_XGROUP DGROUP __XDUMMY,C166_US
__XDUMMY SECTION DATA WORD PUBLIC
__XDUMMY ENDS
CSTART_RBANK REGDEF R0-R15 ; Register usage
SSKDEF 0 ; System stack size
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -