Download 32-bit general purpose microcontroller core User manual

Transcript
User manual
The order of
registers in the
thread context
Register Offset
AWX
0
BWX
4
CWX
8
DWX
12
EWX
16
FWX
20
ESP
24
EIP
28
When initializing Thread list SW has to initialize at least EIP and FWX register of each thread. EIP is a
starting point from which thread will start execution. FWX must contain zero at least in IF flag, because
interrupts at the beginning of thread should be disabled.
Once thread contexts in the list are initialized, application has to place the address to the list into BWX
register and execute sbl command. This command has one parameter: number of threads in the list minus 1.
Note that the thread context with index zero does not have to be initialized because it represents currently
working process.
Example
Let's make a project which contains 3 threads:
• Main thread (supervisor)
• Uart thread used to communicate by UART
• Terminal thread used to output some data on the screen
The entry point of Uart thread will be called UartProcess and the entry point of
Terminal thread we will call TerminalProcess. Each thread will be implemented in
a separate source file for simplicity. So, project will contain 3 files:
• Main.asm
• Uart.asm
• Term.asm
At the beginning of thread list initialization we will fill all registers with
zeros to avoid garbage and basically to initialize FWX (Flags). Then we will
specify the entry point for each thread.
19/37