mirror of
https://github.com/micropython/micropython.git
synced 2026-05-01 21:30:14 +02:00
b67c55cb4f
This commit optimises the lookup of opcodes' condition codes, in order to take up less code than before. The original data was held in a table containing the condition code value (an incrementing 0-based integer) and the two condition ASCII characters. Given that the condition code value also matches the entry's index in the table, that can be safely omitted. This saves 52 bytes when compiled for Thumb. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
66 lines
882 B
Python
66 lines
882 B
Python
# test bcc instructions, narrow and wide versions
|
|
|
|
|
|
RESULT = []
|
|
|
|
|
|
TEMPLATE = """
|
|
@micropython.asm_thumb
|
|
def t(r0):
|
|
mov(r1, r0)
|
|
|
|
mov(r0, 10)
|
|
cmp(r1, 1)
|
|
b{}(next1)
|
|
|
|
b(end)
|
|
|
|
label(next1)
|
|
|
|
mov(r0, 20)
|
|
cmp(r1, 2)
|
|
b{}_n(next2)
|
|
|
|
b(end)
|
|
|
|
label(next2)
|
|
mov(r0, 30)
|
|
cmp(r1, 3)
|
|
b{}_w(next3)
|
|
|
|
b(end)
|
|
|
|
label(next3)
|
|
mov(r0, 0)
|
|
|
|
label(end)
|
|
"""
|
|
|
|
try:
|
|
for code in (
|
|
"eq",
|
|
"ne",
|
|
"cs",
|
|
"cc",
|
|
"mi",
|
|
"pl",
|
|
"vs",
|
|
"vc",
|
|
"hi",
|
|
"ls",
|
|
"ge",
|
|
"lt",
|
|
"gt",
|
|
"le",
|
|
):
|
|
exec(TEMPLATE.format(code, code, code))
|
|
RESULT.append("B" + code.upper())
|
|
for i in range(4):
|
|
RESULT.append(t(i))
|
|
except MemoryError:
|
|
print("SKIP-TOO-LARGE")
|
|
raise SystemExit
|
|
|
|
for line in RESULT:
|
|
print(line)
|