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
6addc89e
Commit
6addc89e
authored
Nov 4, 2013
by
Damien
Browse files
Options
Downloads
Patches
Plain Diff
Byte code for SMALL_INT uses 3 bytes for integer.
parent
0c70f887
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/emitbc.c
+4
-3
4 additions, 3 deletions
py/emitbc.c
py/vm.c
+7
-2
7 additions, 2 deletions
py/vm.c
with
11 additions
and
5 deletions
py/emitbc.c
+
4
−
3
View file @
6addc89e
...
@@ -106,11 +106,12 @@ static void emit_write_byte_1_byte(emit_t* emit, byte b1, uint b2) {
...
@@ -106,11 +106,12 @@ static void emit_write_byte_1_byte(emit_t* emit, byte b1, uint b2) {
}
}
static
void
emit_write_byte_1_int
(
emit_t
*
emit
,
byte
b1
,
int
num
)
{
static
void
emit_write_byte_1_int
(
emit_t
*
emit
,
byte
b1
,
int
num
)
{
assert
((
num
&
(
~
0x7fff
))
==
0
||
(
num
&
(
~
0x7fff
))
==
(
~
0x7fff
));
assert
((
num
&
(
~
0x7fff
ff
))
==
0
||
(
num
&
(
~
0x7fff
ff
))
==
(
~
0x7fff
ff
));
byte
*
c
=
emit_get_cur_to_write_bytes
(
emit
,
3
);
byte
*
c
=
emit_get_cur_to_write_bytes
(
emit
,
4
);
c
[
0
]
=
b1
;
c
[
0
]
=
b1
;
c
[
1
]
=
num
;
c
[
1
]
=
num
;
c
[
2
]
=
num
>>
8
;
c
[
2
]
=
num
>>
8
;
c
[
3
]
=
num
>>
16
;
}
}
static
void
emit_write_byte_1_uint
(
emit_t
*
emit
,
byte
b1
,
uint
num
)
{
static
void
emit_write_byte_1_uint
(
emit_t
*
emit
,
byte
b1
,
uint
num
)
{
...
@@ -186,8 +187,8 @@ static void emit_bc_label_assign(emit_t *emit, int l) {
...
@@ -186,8 +187,8 @@ static void emit_bc_label_assign(emit_t *emit, int l) {
emit
->
label_offsets
[
l
]
=
emit
->
code_offset
;
emit
->
label_offsets
[
l
]
=
emit
->
code_offset
;
}
else
if
(
emit
->
pass
==
PASS_3
)
{
}
else
if
(
emit
->
pass
==
PASS_3
)
{
// ensure label offset has not changed from PASS_2 to PASS_3
// ensure label offset has not changed from PASS_2 to PASS_3
//printf("l%d: (at %d vs %d)\n", l, emit->code_offset, emit->label_offsets[l]);
assert
(
emit
->
label_offsets
[
l
]
==
emit
->
code_offset
);
assert
(
emit
->
label_offsets
[
l
]
==
emit
->
code_offset
);
//printf("l%d: (at %d)\n", l, emit->code_offset);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
py/vm.c
+
7
−
2
View file @
6addc89e
...
@@ -75,11 +75,11 @@ bool py_execute_byte_code_2(const byte *code, const byte **ip_in_out, py_obj_t *
...
@@ -75,11 +75,11 @@ bool py_execute_byte_code_2(const byte *code, const byte **ip_in_out, py_obj_t *
break
;
break
;
case
PYBC_LOAD_CONST_SMALL_INT
:
case
PYBC_LOAD_CONST_SMALL_INT
:
snum
=
ip
[
0
]
|
(
ip
[
1
]
<<
8
);
snum
=
ip
[
0
]
|
(
ip
[
1
]
<<
8
)
|
(
ip
[
2
]
<<
16
)
;
if
(
snum
&
0x8000
)
{
if
(
snum
&
0x8000
)
{
snum
|=
~
0xffff
;
snum
|=
~
0xffff
;
}
}
ip
+=
2
;
ip
+=
3
;
PUSH
((
py_obj_t
)(
snum
<<
1
|
1
));
PUSH
((
py_obj_t
)(
snum
<<
1
|
1
));
break
;
break
;
...
@@ -162,6 +162,11 @@ bool py_execute_byte_code_2(const byte *code, const byte **ip_in_out, py_obj_t *
...
@@ -162,6 +162,11 @@ bool py_execute_byte_code_2(const byte *code, const byte **ip_in_out, py_obj_t *
rt_store_name
(
qstr
,
POP
());
rt_store_name
(
qstr
,
POP
());
break
;
break
;
case
PYBC_STORE_GLOBAL
:
DECODE_QSTR
;
rt_store_global
(
qstr
,
POP
());
break
;
case
PYBC_STORE_ATTR
:
case
PYBC_STORE_ATTR
:
DECODE_QSTR
;
DECODE_QSTR
;
rt_store_attr
(
sp
[
0
],
qstr
,
sp
[
1
]);
rt_store_attr
(
sp
[
0
],
qstr
,
sp
[
1
]);
...
...
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