你好

2023-04-06by@rikumo.rinnku-PPSHD&@codeDocCom.Model: gpt-3.5
rikumo.rinnku-PPSHD

Acting as a code proofreader.
Your task is to add comments to the code below. The comments should explain what the code does.
Add document at start of the function.

Avatar
Avatar

你好!有什么我可以帮助您的吗?

rikumo.rinnku-PPSHD

EXTERN Running
EXPORT OSCtxsw
OS_CPO_SR_SAVE
MRS R0,PRIMASK
CPSID 1
BX LR
OS_CPU_SR_Restore
MSR PRIMASK,R0
OSStarthighrdy
LDR R0,=NVIC_STSPRI14
LDR R1,=NVIC_PENDSV_PRI
STRB R1,[R0]
MOVS R0,#0
MOSR PSP,R0
LDR R0,=OSRunning
MOVS R1,#1
STRB R1,[R0]

OSStartHang
B OSStartHang;

OSIntCtxSw
OS_PendSV_Handler
CPSID 1;
MRS R0,PSP
CBZ R0,OS_PendSV_Handler_nosowe
SUBS R0,R0,#0X20
STM R0,{R4-R11}
LDR R1,=OSTCBCUR
LDR R1,[R1]
STR R0,[R1]
OS_CPU_PendSVHandler_nosowe
PUSH {R14}
LDR R0=OSTaskswHook
BLX R0
POP {R14}
LDR R0,=OSPrioCur
LDR R1=OSPrioHighRdy
LDRB R2,[R1]
STRB R2,[R0]

LDR R0,=OSTCBCUR
LDR R1,=OSTCBHighRdy
LDR R2,[R1]
STR R2,[R1]
STR R2,[R0]
LDR R0,[R12]
LDR R0,{R4-R11}
ADDS R0,R0,#0X20
MSR PSP,R0

Avatar
Avatar
  • This function contains assembly code for context switching of tasks
  • in an operating system. It performs the following tasks:
    • Saves the PRIMASK register value
    • Disable interrupts
    • Set priority of PendSV interrupt
    • Set the stack pointer for the current task to PSP
    • Set the OSRunning flag to