📄 os.asm
字号:
; Copyright (C) 2004 Pavel Baranov (pbaranov@spb.lucent.com)
;
; The programm is a kernel of multitask system for PIC16C84.
; The following addresses are reserved:
; from 0x00 to 0x0d
;
; Each task must be in a separate file called t<task number>.asm
; Each task file must contain the following subroutines:
; t<task number>_init
; t<task number>_run
; t<task number>_inter
;
; task numbers are ranged from 0 to 'task count'-1.
;
; After reset allinit subroutine is called. It is located in
; init.asm file and should be provided by user.
; Than t<task number>_init subroutines are called.
; Then the t<task number>_run subroutines are called in cycle.
; The task with the lowest number is called first.
;
; Each task must have a t<task number>_inter routine wich is
; called when an interrupt occures. The task with the lowest
; number is called first.
;
; Users' variables can be plased from address usrvar in
; file var.asm
;
; Note that stack is decreased by 1
;
; Let's summarise what is needed for an application:
; 1) change task count in os.asm variable tsknum
; 2) insert your own initialisation code in init.asm
; 3) create relevant nubler af t?.asm files (e.g. t0.asm, t1.asm ...)
; 4) insert into each t?.asm file t?_init, t?_run and t?_inter subroutines
;
include "..\mpasm\p16c84.inc"
title "Constants *****************************************"
tsknum equ 0x2 ;task count Insert your own!
title "Variables *****************************************"
w_tmp equ 0x0c
s_tmp equ 0x0d
usrval equ 0x0e ;start of users' variables
include "var.asm"
title "Macros ********************************************"
TSK macro str1, str2
local a = 0
while a<tsknum
str1#v(a)str2
a += 1
endw
endm
title "Code **********************************************"
subtitle "Jump to start **********************************"
ORG 0
call allinit
subtitle "Interrupt **************************************"
ORG 4
inter movwf w_tmp
swapf STATUS, W
movwf s_tmp
TSK call t, _inter
swapf s_tmp, W
movwf STATUS
swapf w_tmp, F
swapf w_tmp, W
btfsc INTCON, T0IF
bcf INTCON, T0IF ;clear TMR0 overflow interrupt flag
btfsc INTCON, INTF
bcf INTCON, INTF ;clear RB0/INT interrupt flag
btfsc INTCON, RBIF
bcf INTCON, RBIF ;clear RB Port Change interrupt flag
retfie
subtitle "Start ******************************************"
start TSK call t, _init
subtitle "Core *******************************************"
core TSK call t, _run
goto core
subtitle "Include ****************************************"
include init.asm
TSK include <t, .asm>
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -