📄 main.asm
字号:
;*******************************************************************
;* This stationery serves as the framework for a user application. *
;* For a more comprehensive program that demonstrates the more *
;* advanced functionality of this processor, please see the *
;* demonstration applications, located in the examples *
;* subdirectory of the "Freescale CodeWarrior for HC08" program *
;* directory. *
;*******************************************************************
; export symbols
XDEF _Startup, main
; we export both '_Startup' and 'main' as symbols. Either can
; be referenced in the linker .prm file or from C/C++ later on
; Include derivative-specific definitions
INCLUDE 'derivative.inc'
; variable/data section
TINY_RAM_VARS: SECTION RS08_SHORT ; Insert here your data definition
COUNTER1: DS.B 1
COUNTER2: DS.B 1
; code section
MyCode: SECTION
main:
_Startup:
MOV #HIGH_6_13(SOPT), PAGESEL
MOV #$03, MAP_ADDR_6(SOPT) ; Disables COP, enables BKGD (PTA3) and RESET (PTA2)
MOV #$10,PTADD ; PTA5 as Output
MOV #$02,KBIPE ; PTA1 as KBI
MOV #$06,KBISC ; Clear any false interrupts and unmask KBI
mainLoop:
JSR Set_FEI
FEI_Delay:
JSR Delay
MOV #HIGH_6_13(SIP1), PAGESEL
BRCLR 4, MAP_ADDR_6(SIP1),FEI_Delay ; Branch if KBI not pending
JSR Set_FBI
FBI_Delay:
JSR Delay
MOV #HIGH_6_13(SIP1), PAGESEL
BRCLR 4, MAP_ADDR_6(SIP1),FBI_Delay ; Branch if KBI not pending
JSR Set_FBILP
FBILP_Delay:
JSR Delay
MOV #HIGH_6_13(SIP1), PAGESEL
BRCLR 4, MAP_ADDR_6(SIP1),FBILP_Delay ; Branch if KBI not pending
BRA mainLoop
Set_FEI:
BSET KBISC_KBACK,KBISC ; Clear KBI interrupt
LDA #$00
STA ICSC1
LDA #$C0
STA ICSC2
RTS
Set_FBI:
BSET KBISC_KBACK,KBISC ; Clear KBI interrupt
LDA #$40
STA ICSC1
LDA #$00
STA ICSC2
RTS
Set_FBILP:
BSET KBISC_KBACK,KBISC ; Clear KBI interrupt
LDA #$40
STA ICSC1
LDA #$08
STA ICSC2
RTS
Delay:
MOV #10, COUNTER2
MOV #0, COUNTER1
;DO ALOT OF WAITING
loop: ;delay by software
BRSET 4, MAP_ADDR_6(SIP1),exit_Delay ; Branch if KBI pending
DBNZ COUNTER1, loop
DBNZ COUNTER2,loop
exit_Delay:
LDA PTAD
EOR #$10
STA PTAD
RTS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -