I have the following basic python function:
def squared(num):
if num < 2:
print ('OK!')
return num * num
Which produces the following bytecode:
>>> dis.dis(squared)
2 0 LOAD_FAST 0 (num)
3 LOAD_CONST 1 (2)
6 COMPARE_OP 0 (<)
9 POP_JUMP_IF_FALSE 20
3 12 LOAD_CONST 2 ('OK!')
15 PRINT_ITEM
16 PRINT_NEWLINE
17 JUMP_FORWARD 0 (to 20)
4 >> 20 LOAD_FAST 0 (num)
23 LOAD_FAST 0 (num)
26 BINARY_MULTIPLY
27 RETURN_VALUE
Most of the above look like mov
and jmp
-type operators. However, what do the following most closely mean in assembly?
LOAD_FAST
, LOAD_CONST
?
What might be the closest assembly instructions for this?