Mercurial > lcfOS
comparison python/target/armframe.py @ 341:4d204f6f7d4e devel
Rewrite of assembler parts
author | Windel Bouwman |
---|---|
date | Fri, 28 Feb 2014 18:07:14 +0100 |
parents | e9fe6988497c |
children |
comparison
equal
deleted
inserted
replaced
340:c7cc54c0dfdf | 341:4d204f6f7d4e |
---|---|
1 from ppci import ir | 1 from ppci import ir |
2 from .basetarget import Label, Comment, Alignment, LabelRef, DebugInfo, Nop | 2 from .basetarget import Label, Comment, Alignment, LabelRef, DebugInfo, Nop |
3 from .basetarget import Imm7 | 3 from .basetarget import Imm7 |
4 from ppci.irmach import makeIns, Frame | 4 from ppci.irmach import makeIns, Frame |
5 from .arminstructions import Dcd, AddSp, SubSp, Push, Pop, Mov2 | 5 from .arminstructions import Dcd, AddSp, SubSp, Push, Pop, Mov2 |
6 from .arminstructions import R0, R1, R2, R3, R4, R5, R6, R7, LR, PC, SP | 6 from .armregisters import R0, R1, R2, R3, R4, R5, R6, R7, LR, PC, SP |
7 | 7 |
8 | 8 |
9 class ArmFrame(Frame): | 9 class ArmFrame(Frame): |
10 """ Arm specific frame for functions. """ | 10 """ Arm specific frame for functions. """ |
11 def __init__(self, name): | 11 def __init__(self, name): |
62 pre = [ | 62 pre = [ |
63 Label(self.name), # Label indication function | 63 Label(self.name), # Label indication function |
64 Push({LR, R7}) | 64 Push({LR, R7}) |
65 ] | 65 ] |
66 if self.stacksize > 0: | 66 if self.stacksize > 0: |
67 pre.append(SubSp(SP, SP, Imm7(self.stacksize))) # Reserve stack space | 67 pre.append(SubSp(self.stacksize)) # Reserve stack space |
68 pre += [ | 68 pre += [ |
69 Mov2(R7, SP) # Setup frame pointer | 69 Mov2(R7, SP) # Setup frame pointer |
70 ] | 70 ] |
71 return pre | 71 return pre |
72 | 72 |
73 def epilogue(self): | 73 def epilogue(self): |
74 """ Return epilogue sequence for a frame. Adjust frame pointer and add constant pool """ | 74 """ Return epilogue sequence for a frame. Adjust frame pointer and add constant pool """ |
75 post = [] | 75 post = [] |
76 if self.stacksize > 0: | 76 if self.stacksize > 0: |
77 post.append(AddSp(SP, SP, Imm7(self.stacksize))) | 77 post.append(AddSp(self.stacksize)) |
78 post += [ | 78 post += [ |
79 Pop({PC, R7}), | 79 Pop({PC, R7}), |
80 Alignment(4) # Align at 4 bytes | 80 Alignment(4) # Align at 4 bytes |
81 ] | 81 ] |
82 # Add constant literals: | 82 # Add constant literals: |