Mercurial > hg > Members > tobaru > CbC_xv6
comparison src/asm.S @ 0:83c23a36980d
Init
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 26 May 2017 23:11:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:83c23a36980d |
---|---|
1 #include "arm.h" | |
2 | |
3 .text | |
4 .code 32 | |
5 | |
6 .global set_stk | |
7 .global get_fp | |
8 | |
9 # set the stack for IRQ mode, we can use r0-r3 for free | |
10 # input: r0 - #mode, r1 - stk | |
11 set_stk: | |
12 # switch to the IRQ mode | |
13 MRS r2, cpsr | |
14 BIC r2, r2, #MODE_MASK | |
15 ORR r2, r2, r0 | |
16 MSR cpsr_cxsf, r2 | |
17 | |
18 # set the stack pointer, sp register is banked, so we need to switch mode | |
19 MOV sp, r1 | |
20 | |
21 # switch back to the SVC mode | |
22 BIC r2, r2, #MODE_MASK | |
23 ORR r2, r2, #SVC_MODE | |
24 MSR cpsr_cxsf, r2 | |
25 | |
26 # return | |
27 bx lr | |
28 | |
29 # return the frame pointer for the current function | |
30 get_fp: | |
31 MOV r0, fp | |
32 bx lr |