📄 mainasm.asm
字号:
;-----------------------------------------------------------------------------
; Include Files
;-----------------------------------------------------------------------------
include "m8c.inc" ; part specific constants and macros
include "PSoCAPI.inc" ; PSoC API definitions for all User Modules
include "memory.inc"
;-----------------------------------------------------------------------------
; Global Symbols
;-----------------------------------------------------------------------------
export _mainasm
export _Counter16_ISR_ASM
;-----------------------------------------------------------------------------
; FUNCTION NAME: _mainasm
;
; DESCRIPTION:
; Main function. Performs system initialization and loops infinitely.
;
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None
; RETURNS: Nothing.
; SIDE EFFECTS: None.
;
; THEORY of OPERATION or PROCEDURE:
; 1) Enable Interrupts of user modules and Global Interrupt
; 2) Start the user modules
; 3) Loop Infinitely
;
_mainasm:
mov reg[PRT2DR], 0x00 ;Initialise port2 to 0x00
M8C_EnableGInt ;Enable the global Interrupt
call Counter16_EnableInt ;Enable the Coutner Interrupt
call Counter16_Start ;Start the Counter
.terminate: ;Infinite loop. Processing done only at Counter16 ISR
ljmp .terminate
ret
;-----------------------------------------------------------------------------
; FUNCTION NAME: _Counter16_ISR_ASM
;
; DESCRIPTION:
; Interrupt Service routine of Counter16 usermodule written in asm.
; The _Counter16_ISR subroutine In the Counter16int.asm file,
; redirects the flow to this subroutine.
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None
; RETURNS: Nothing.
; SIDE EFFECTS: None.
;
; THEORY of OPERATION or PROCEDURE:
; This ISR is serviced on every Termincal count (ie., normally after of every
; one second, if the input switch at P1[4] is not pressed)
; A counter is incremented and output to PORT-2.
; When the counter reaches 0x10 (ie.,16), it is reset to 0
;
_Counter16_ISR_ASM:
push A ; store Accumulator in stack
RAM_SETPAGE_CUR >_bElapsedCount
inc [_bElapsedCount] ; increment the variable
; (declared in mainc.c, made global using extern command)
cmp [_bElapsedCount], 0x10 ; compare variable with 0x10 (ie.,16)
jnz _outputCount ; if it has not reached 0x10, just output
mov [_bElapsedCount], 0x00 ; else, reset the variable to 0
_outputCount:
mov A,[_bElapsedCount] ; move contents of variable to Acc
mov reg[PRT2DR],A ; output the contents of A onto Port2.
pop A ; retrive old accumulator value from stack
reti
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -