ad_sample.lst
来自「塞普拉思(sypress) 的ad转换应用范例.」· LST 代码 · 共 917 行 · 第 1/5 页
LST
917 行
00E5: 08 PUSH A (0455) push A
00E6: 28 ROMX (0456) romx ; get the MSB of xidata's address
00E7: 53 0C MOV [__r0],A (0457) mov [__r0], A
00E9: 18 POP A (0458) pop A
00EA: 75 INC X (0459) inc X
00EB: 09 00 ADC A,0 (0460) adc A, 0
00ED: 28 ROMX (0461) romx ; get the LSB of xidata's address
00EE: 4B SWAP A,X (0462) swap A, X
00EF: 51 0C MOV A,[12] (0463) mov A, [__r0] ; pXIData (in [A,X]) points to the
(0464) ; XIData structure list in flash
00F1: 80 04 JMP 0x00F6 (0465) jmp .AccessStruct
(0466)
(0467) ; Unpack one element in the xidata "structure list" that specifies the
(0468) ; values of C variables. Each structure contains 3 member elements.
(0469) ; The first is a pointer to a contiguous block of RAM to be initial-
(0470) ; ized. Blocks are always 255 bytes or less in length and never cross
(0471) ; RAM page boundaries. The list terminates when the MSB of the pointer
(0472) ; contains 0xFF. There are two formats for the struct depending on the
(0473) ; value in the second member element, an unsigned byte:
(0474) ; (1) If the value of the second element is non-zero, it represents
(0475) ; the 'size' of the block of RAM to be initialized. In this case, the
(0476) ; third member of the struct is an array of bytes of length 'size' and
(0477) ; the bytes are copied to the block of RAM.
(0478) ; (2) If the value of the second element is zero, the block of RAM is
(0479) ; to be cleared to zero. In this case, the third member of the struct
(0480) ; is an unsigned byte containing the number of bytes to clear.
(0481)
(0482) .AccessNextStructLoop:
00F3: 75 INC X (0483) inc X ; pXIData++
00F4: 09 00 ADC A,0 (0484) adc A, 0
(0485) .AccessStruct: ; Entry point for first block
(0486) ;
(0487) ; Assert: pXIData in [A,X] points to the beginning of an XIData struct.
(0488) ;
00F6: 62 E3 00 MOV REG[227],0 (0489) M8C_ClearWDT ; Clear the watchdog for long inits
00F9: 08 PUSH A (0490) push A
00FA: 28 ROMX (0491) romx ; MSB of RAM addr (CPU.A <- *pXIData)
00FB: 60 D5 MOV REG[213],A (0492) mov reg[MVW_PP], A ; for use with MVI write operations
00FD: 74 INC A (0493) inc A ; End of Struct List? (MSB==0xFF?)
00FE: A0 4B JZ 0x014A (0494) jz .C_RTE_WrapUp ; Yes, C runtime environment complete
0100: 18 POP A (0495) pop A ; restore pXIData to [A,X]
0101: 75 INC X (0496) inc X ; pXIData++
0102: 09 00 ADC A,0 (0497) adc A, 0
0104: 08 PUSH A (0498) push A
0105: 28 ROMX (0499) romx ; LSB of RAM addr (CPU.A <- *pXIData)
0106: 53 0C MOV [__r0],A (0500) mov [__r0], A ; RAM Addr now in [reg[MVW_PP],[__r0]]
0108: 18 POP A (0501) pop A ; restore pXIData to [A,X]
0109: 75 INC X (0502) inc X ; pXIData++ (point to size)
010A: 09 00 ADC A,0 (0503) adc A, 0
010C: 08 PUSH A (0504) push A
010D: 28 ROMX (0505) romx ; Get the size (CPU.A <- *pXIData)
010E: A0 1C JZ 0x012B (0506) jz .ClearRAMBlockToZero ; If Size==0, then go clear RAM
0110: 53 0B MOV [__r1],A (0507) mov [__r1], A ; else downcount in __r1
0112: 18 POP A (0508) pop A ; restore pXIData to [A,X]
(0509)
(0510) .CopyNextByteLoop:
(0511) ; For each byte in the structure's array member, copy from flash to RAM.
(0512) ; Assert: pXIData in [A,X] points to previous byte of flash source;
(0513) ; [reg[MVW_PP],[__r0]] points to next RAM destination;
(0514) ; __r1 holds a non-zero count of the number of bytes remaining.
(0515) ;
0113: 75 INC X (0516) inc X ; pXIData++ (point to next data byte)
0114: 09 00 ADC A,0 (0517) adc A, 0
0116: 08 PUSH A (0518) push A
0117: 28 ROMX (0519) romx ; Get the data value (CPU.A <- *pXIData)
0118: 3F 0C MVI [__r0],A (0520) mvi [__r0], A ; Transfer the data to RAM
011A: 47 0C FF TST [12],255 (0521) tst [__r0], 0xff ; Check for page crossing
011D: B0 06 JNZ 0x0124 (0522) jnz .CopyLoopTail ; No crossing, keep going
011F: 5D D5 MOV A,REG[213] (0523) mov A, reg[ MVW_PP] ; If crossing, bump MVW page reg
0121: 74 INC A (0524) inc A
0122: 60 D5 MOV REG[213],A (0525) mov reg[ MVW_PP], A
(0526) .CopyLoopTail:
0124: 18 POP A (0527) pop A ; restore pXIData to [A,X]
0125: 7A 0B DEC [__r1] (0528) dec [__r1] ; End of this array in flash?
0127: BF EB JNZ 0x0113 (0529) jnz .CopyNextByteLoop ; No, more bytes to copy
0129: 8F C9 JMP 0x00F3 (0530) jmp .AccessNextStructLoop ; Yes, initialize another RAM block
(0531)
(0532) .ClearRAMBlockToZero:
012B: 18 POP A (0533) pop A ; restore pXIData to [A,X]
012C: 75 INC X (0534) inc X ; pXIData++ (point to next data byte)
012D: 09 00 ADC A,0 (0535) adc A, 0
012F: 08 PUSH A (0536) push A
0130: 28 ROMX (0537) romx ; Get the run length (CPU.A <- *pXIData)
0131: 53 0B MOV [__r1],A (0538) mov [__r1], A ; Initialize downcounter
0133: 50 00 MOV A,0 (0539) mov A, 0 ; Initialize source data
(0540)
(0541) .ClearRAMBlockLoop:
(0542) ; Assert: [reg[MVW_PP],[__r0]] points to next RAM destination and
(0543) ; __r1 holds a non-zero count of the number of bytes remaining.
(0544) ;
0135: 3F 0C MVI [__r0],A (0545) mvi [__r0], A ; Clear a byte
0137: 47 0C FF TST [12],255 (0546) tst [__r0], 0xff ; Check for page crossing
013A: B0 08 JNZ 0x0143 (0547) jnz .ClearLoopTail ; No crossing, keep going
013C: 5D D5 MOV A,REG[213] (0548) mov A, reg[ MVW_PP] ; If crossing, bump MVW page reg
013E: 74 INC A (0549) inc A
013F: 60 D5 MOV REG[213],A (0550) mov reg[ MVW_PP], A
0141: 50 00 MOV A,0 (0551) mov A, 0 ; Restore the zero used for clearing
(0552) .ClearLoopTail:
0143: 7A 0B DEC [__r1] (0553) dec [__r1] ; Was this the last byte?
0145: BF EF JNZ 0x0135 (0554) jnz .ClearRAMBlockLoop ; No, continue
0147: 18 POP A (0555) pop A ; Yes, restore pXIData to [A,X] and
0148: 8F AA JMP 0x00F3 (0556) jmp .AccessNextStructLoop ; initialize another RAM block
(0557)
(0558) .C_RTE_WrapUp:
014A: 18 POP A (0559) pop A ; balance stack
(0560)
(0561) ENDIF ; SYSTEM_LARGE_MEMORY_MODEL
(0562)
(0563) C_RTE_Done:
(0564)
(0565) ENDIF ; C_LANGUAGE_SUPPORT
(0566)
(0567) ;-------------------------------
(0568) ; Voltage Stabilization for SMP
(0569) ;-------------------------------
(0570)
(0571) IF ( POWER_SETTING & POWER_SET_5V0) ; 5.0V Operation
(0572) IF ( SWITCH_MODE_PUMP ^ 1 ) ; SMP is operational
(0573) ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(0574) ; When using the SMP at 5V, we must wait for Vdd to slew from 3.1V to
(0575) ; 5V before enabling the Precision Power-On Reset (PPOR).
(0576) ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(0577) or reg[INT_MSK0],INT_MSK0_SLEEP
(0578) M8C_SetBank1
(0579) and reg[OSC_CR0], ~OSC_CR0_SLEEP
(0580) or reg[OSC_CR0], OSC_CR0_SLEEP_512Hz
(0581) M8C_SetBank0
(0582) M8C_ClearWDTAndSleep ; Restart the sleep timer
(0583) mov reg[INT_VC], 0 ; Clear all pending interrupts
(0584) .WaitFor2ms:
(0585) tst reg[INT_CLR0], INT_MSK0_SLEEP ; Test the SleepTimer Interrupt Status
(0586) jz .WaitFor2ms ; Branch fails when 2 msec has passed
(0587) ENDIF ; SMP is operational
(0588) ENDIF ; 5.0V Operation
(0589)
(0590) ;-------------------------------
(0591) ; Set Power-On Reset (POR) Level
(0592) ;-------------------------------
014B: 71 10 OR F,16 (0593) M8C_SetBank1
(0594)
(0595) IF (POWER_SETTING & POWER_SET_5V0) ; 5.0V Operation?
(0596) IF (POWER_SETTING & POWER_SET_SLOW_IMO) ; and Slow Mode?
(0597) ELSE ; No, fast mode
(0598) IF ( CPU_CLOCK_JUST ^ OSC_CR0_CPU_24MHz ) ; As fast as 24MHz?
(0599) ; no, set midpoint POR in user code, if desired
(0600) ELSE ; 24HMz ;
(0601) or reg[VLT_CR], VLT_CR_POR_HIGH ; yes, highest POR trip point required
(0602) ENDIF ; 24MHz
(0603) ENDIF ; Slow Mode
(0604) ENDIF ; 5.0V Operation
(0605)
014D: 70 EF AND F,239 (0606) M8C_SetBank0
(0607)
(0608) ;----------------------------
(0609) ; Wrap up and invoke "main"
(0610) ;----------------------------
(0611)
(0612) ; Disable the Sleep interrupt that was used for timing above. In fact,
(0613) ; no interrupts should be enabled now, so may as well clear the register.
(0614) ;
014F: 62 E0 00 MOV REG[224],0 (0615) mov reg[INT_MSK0],0
(0616)
(0617) ; Everything has started OK. Now select requested CPU & sleep frequency.
(0618) ; And put decimator in full mode so it does not consume too much current.
(0619) ;
0152: 71 10 OR F,16 (0620) M8C_SetBank1
0154: 62 E0 00 MOV REG[224],0 (0621) mov reg[OSC_CR0],(SELECT_32K_JUST | PLL_MODE_JUST | SLEEP_TIMER_JUST | CPU_CLOCK_JUST)
0157: 43 E7 80 OR REG[231],128 (0622) or reg[DEC_CR2],80h ; Put decimator in full mode
015A: 70 EF AND F,239 (0623) M8C_SetBank0
(0624)
(0625) ; Global Interrupt are NOT enabled, this should be done in main().
(0626) ; LVD is set but will not occur unless Global Interrupts are enabled.
(0627) ; Global Interrupts should be enabled as soon as possible in main().
(0628) ;
015C: 62 E2 00 MOV REG[226],0 (0629) mov reg[INT_VC],0 ; Clear any pending interrupts which may
(0630) ; have been set during the boot process.
(0631) IF (TOOLCHAIN & HITECH)
(0632) ljmp startup ; Jump to C compiler startup code
(0633) ELSE
(0634) IF ENABLE_LJMP_TO_MAIN
(0635) ljmp _main ; goto main (no return)
(0636) ELSE
015F: 7C 06 D6 LCALL _main (0637) lcall _main ; call main
(0638) .Exit:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?