Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
9f142f0c
Commit
9f142f0c
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: For inline assembler, add bcc_n and bcc_w ops.
Addresses issue #1143.
parent
565da3f5
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
py/asmthumb.c
+14
-9
14 additions, 9 deletions
py/asmthumb.c
py/asmthumb.h
+1
-1
1 addition, 1 deletion
py/asmthumb.h
py/emitinlinethumb.c
+4
-2
4 additions, 2 deletions
py/emitinlinethumb.c
with
19 additions
and
12 deletions
py/asmthumb.c
+
14
−
9
View file @
9f142f0c
...
...
@@ -307,16 +307,25 @@ bool asm_thumb_b_n_label(asm_thumb_t *as, uint label) {
#define OP_BCC_N(cond, byte_offset) (0xd000 | ((cond) << 8) | (((byte_offset) >> 1) & 0x00ff))
bool
asm_thumb_bcc_n_label
(
asm_thumb_t
*
as
,
int
cond
,
uint
label
)
{
// all these bit arithmetics need coverage testing!
#define OP_BCC_W_HI(cond, byte_offset) (0xf000 | ((cond) << 6) | (((byte_offset) >> 10) & 0x0400) | (((byte_offset) >> 14) & 0x003f))
#define OP_BCC_W_LO(byte_offset) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff))
bool
asm_thumb_bcc_nw_label
(
asm_thumb_t
*
as
,
int
cond
,
uint
label
,
bool
wide
)
{
mp_uint_t
dest
=
get_label_dest
(
as
,
label
);
mp_int_t
rel
=
dest
-
as
->
code_offset
;
rel
-=
4
;
// account for instruction prefetch, PC is 4 bytes ahead of this instruction
if
(
!
wide
)
{
if
(
SIGNED_FIT9
(
rel
))
{
asm_thumb_op16
(
as
,
OP_BCC_N
(
cond
,
rel
));
return
true
;
}
else
{
return
false
;
}
}
else
{
asm_thumb_op32
(
as
,
OP_BCC_W_HI
(
cond
,
rel
),
OP_BCC_W_LO
(
rel
));
return
true
;
}
}
#define OP_BL_HI(byte_offset) (0xf000 | (((byte_offset) >> 12) & 0x07ff))
...
...
@@ -416,10 +425,6 @@ void asm_thumb_b_label(asm_thumb_t *as, uint label) {
}
}
// all these bit arithmetics need coverage testing!
#define OP_BCC_W_HI(cond, byte_offset) (0xf000 | ((cond) << 6) | (((byte_offset) >> 10) & 0x0400) | (((byte_offset) >> 14) & 0x003f))
#define OP_BCC_W_LO(byte_offset) (0x8000 | ((byte_offset) & 0x2000) | (((byte_offset) >> 1) & 0x0fff))
void
asm_thumb_bcc_label
(
asm_thumb_t
*
as
,
int
cond
,
uint
label
)
{
mp_uint_t
dest
=
get_label_dest
(
as
,
label
);
mp_int_t
rel
=
dest
-
as
->
code_offset
;
...
...
This diff is collapsed.
Click to expand it.
py/asmthumb.h
+
1
−
1
View file @
9f142f0c
...
...
@@ -216,7 +216,7 @@ void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_
// these return true if the destination is in range, false otherwise
bool
asm_thumb_b_n_label
(
asm_thumb_t
*
as
,
uint
label
);
bool
asm_thumb_bcc_n_label
(
asm_thumb_t
*
as
,
int
cond
,
uint
label
);
bool
asm_thumb_bcc_n
w
_label
(
asm_thumb_t
*
as
,
int
cond
,
uint
label
,
bool
wide
);
bool
asm_thumb_bl_label
(
asm_thumb_t
*
as
,
uint
label
);
void
asm_thumb_mov_reg_i32
(
asm_thumb_t
*
as
,
uint
reg_dest
,
mp_uint_t
i32_src
);
// convenience
...
...
This diff is collapsed.
Click to expand it.
py/emitinlinethumb.c
+
4
−
2
View file @
9f142f0c
...
...
@@ -378,7 +378,9 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_a
}
else
if
(
strcmp
(
op_str
,
"bx"
)
==
0
)
{
mp_uint_t
r
=
get_arg_reg
(
emit
,
op_str
,
pn_args
[
0
],
15
);
asm_thumb_op16
(
emit
->
as
,
0x4700
|
(
r
<<
3
));
}
else
if
(
op_str
[
0
]
==
'b'
&&
op_len
==
3
)
{
}
else
if
(
op_str
[
0
]
==
'b'
&&
(
op_len
==
3
||
(
op_len
==
5
&&
op_str
[
3
]
==
'_'
&&
(
op_str
[
4
]
==
'n'
||
op_str
[
4
]
==
'w'
))))
{
mp_uint_t
cc
=
-
1
;
for
(
mp_uint_t
i
=
0
;
i
<
MP_ARRAY_SIZE
(
cc_name_table
);
i
++
)
{
if
(
op_str
[
1
]
==
cc_name_table
[
i
].
name
[
0
]
&&
op_str
[
2
]
==
cc_name_table
[
i
].
name
[
1
])
{
...
...
@@ -389,7 +391,7 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_a
goto
unknown_op
;
}
int
label_num
=
get_arg_label
(
emit
,
op_str
,
pn_args
[
0
]);
if
(
!
asm_thumb_bcc_n_label
(
emit
->
as
,
cc
,
label_num
))
{
if
(
!
asm_thumb_bcc_n
w
_label
(
emit
->
as
,
cc
,
label_num
,
op_len
==
5
&&
op_str
[
4
]
==
'w'
))
{
goto
branch_not_in_range
;
}
}
else
if
(
op_str
[
0
]
==
'i'
&&
op_str
[
1
]
==
't'
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment