Skip to content

Commit

Permalink
Fail in a controlled way for asm_thumb use. (#82)
Browse files Browse the repository at this point in the history
Closes #81
  • Loading branch information
microbit-matt-hillsdon authored Oct 10, 2022
1 parent b721da6 commit f266924
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ <h1>MicroPython-micro:bit simulator example embedding</h1>
<option value="compass">Compass</option>
<option value="data_logging">Data logging</option>
<option value="display">Display</option>
<option value="inline_assembler">Inline assembler</option>
<option value="microphone">Microphone</option>
<option value="music">Music</option>
<option value="pin_logo">Pin logo</option>
Expand Down
12 changes: 12 additions & 0 deletions src/examples/inline_assembler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from microbit import *

# Unsupported in the simulator
@micropython.asm_thumb
def asm_add(r0, r1):
add(r0, r0, r1)

while True:
if button_a.was_pressed():
print(1 + 2)
elif button_b.was_pressed():
print(asm_add(1, 2))
3 changes: 3 additions & 0 deletions src/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,7 @@ extern uint32_t rng_generate_random_word(void);
#define MICROPY_MACHINE_MEM_GET_READ_ADDR machine_mem_get_read_addr
#define MICROPY_MACHINE_MEM_GET_WRITE_ADDR machine_mem_get_write_addr

#define MICROPY_MAKE_POINTER_CALLABLE(p) \
((mp_raise_NotImplementedError(MP_ERROR_TEXT("simulator limitation: asm_thumb code"))), p)

#endif

0 comments on commit f266924

Please sign in to comment.