From f26692426c1ee1cd51f68435e6db9947f7e7929a Mon Sep 17 00:00:00 2001 From: Matt Hillsdon <44397098+microbit-matt-hillsdon@users.noreply.github.com> Date: Mon, 10 Oct 2022 17:04:07 +0100 Subject: [PATCH] Fail in a controlled way for asm_thumb use. (#82) Closes https://github.com/microbit-foundation/micropython-microbit-v2-simulator/issues/81 --- src/demo.html | 1 + src/examples/inline_assembler.py | 12 ++++++++++++ src/mpconfigport.h | 3 +++ 3 files changed, 16 insertions(+) create mode 100644 src/examples/inline_assembler.py diff --git a/src/demo.html b/src/demo.html index b578a0e3..cdcbfd44 100644 --- a/src/demo.html +++ b/src/demo.html @@ -88,6 +88,7 @@

MicroPython-micro:bit simulator example embedding

+ diff --git a/src/examples/inline_assembler.py b/src/examples/inline_assembler.py new file mode 100644 index 00000000..56cf82e8 --- /dev/null +++ b/src/examples/inline_assembler.py @@ -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)) \ No newline at end of file diff --git a/src/mpconfigport.h b/src/mpconfigport.h index 24c1c717..852e2685 100644 --- a/src/mpconfigport.h +++ b/src/mpconfigport.h @@ -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