From 9cf08cdbe46db1acb141946230cad8626280ebbe Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sun, 6 Feb 2022 13:06:16 -0800 Subject: [PATCH] Large step towards inlining builting dictionary. --- ueforth/common/forth_namespace_tests.fs | 1 + ueforth/common/interp.h | 24 +- ueforth/common/opcodes.h | 17 +- ueforth/esp32/builtins.h | 428 ++++++++++++------------ ueforth/esp32/options.h | 6 + ueforth/esp32/print-builtins.cpp | 10 +- ueforth/esp32/sim_main.cpp | 4 +- ueforth/web/dump_web_opcodes.c | 12 +- ueforth/windows/interp.h | 24 +- 9 files changed, 283 insertions(+), 243 deletions(-) diff --git a/ueforth/common/forth_namespace_tests.fs b/ueforth/common/forth_namespace_tests.fs index 1035539..30c3434 100644 --- a/ueforth/common/forth_namespace_tests.fs +++ b/ueforth/common/forth_namespace_tests.fs @@ -201,6 +201,7 @@ e: check-extra-opcodes e: check-core-opcodes out: ; + out: foo out: EXIT out: : out: IMMEDIATE diff --git a/ueforth/common/interp.h b/ueforth/common/interp.h index 46b3df3..2e9fcf6 100644 --- a/ueforth/common/interp.h +++ b/ueforth/common/interp.h @@ -17,24 +17,36 @@ #define ADDR_DOCOLON && OP_DOCOLON #define ADDR_DOCREATE && OP_DOCREATE #define ADDR_DODOES && OP_DODOES - + static cell_t *forth_run(cell_t *init_rp) { - if (!init_rp) { -#define X(name, op, code) create(name, sizeof(name) - 1, name[0] == ';', && OP_ ## op); + static const struct { + const char *name; + cell_t flags; + const void *code; + } foo[] = { +#define XV(flags, name, op, code) name, flags, && OP_ ## op, PLATFORM_OPCODE_LIST EXTRA_OPCODE_LIST OPCODE_LIST -#undef X +#undef XV + }; + + if (!init_rp) { +#define XV(flags, name, op, code) create(name, sizeof(name) - 1, name[0] == ';', && OP_ ## op); + PLATFORM_OPCODE_LIST + EXTRA_OPCODE_LIST + OPCODE_LIST +#undef XV return 0; } register cell_t *ip, *rp, *sp, tos, w; register float *fp; rp = init_rp; UNPARK; NEXT; -#define X(name, op, code) OP_ ## op: { code; } NEXT; +#define XV(flags, name, op, code) OP_ ## op: { code; } NEXT; PLATFORM_OPCODE_LIST EXTRA_OPCODE_LIST OPCODE_LIST -#undef X +#undef XV OP_DOCOLON: ++rp; *rp = (cell_t) ip; ip = (cell_t *) (w + sizeof(cell_t)); NEXT; OP_DOCREATE: DUP; tos = w + sizeof(cell_t) * 2; NEXT; OP_DODOES: DUP; tos = w + sizeof(cell_t) * 2; diff --git a/ueforth/common/opcodes.h b/ueforth/common/opcodes.h index 052abb3..d3465f3 100644 --- a/ueforth/common/opcodes.h +++ b/ueforth/common/opcodes.h @@ -20,7 +20,10 @@ typedef intptr_t cell_t; typedef uintptr_t ucell_t; -#define Y(op, code) X(#op, id ## op, code) +#define YV(flags, op, code) XV(flags, #op, ID_ ## op, code) +#define X(name, op, code) XV(FORTH, name, op, code) +#define Y(op, code) XV(FORTH, #op, ID_ ## op, code) + #define NIP (--sp) #define NIPn(n) (sp -= (n)) #define DROP (tos = *sp--) @@ -57,6 +60,8 @@ typedef int64_t dcell_t; *sp = (cell_t) (d - ((dcell_t) a) * tos); tos = a #endif +enum { FORTH = 0, INTERNALS }; + #define OPCODE_LIST \ X("0=", ZEQUAL, tos = !tos ? -1 : 0) \ X("0<", ZLESS, tos = (tos|0) < 0 ? -1 : 0) \ @@ -97,20 +102,22 @@ typedef int64_t dcell_t; Y(CELL, DUP; tos = sizeof(cell_t)) \ Y(FIND, tos = find((const char *) *sp, tos); --sp) \ Y(PARSE, DUP; tos = parse(tos, sp)) \ - X("S>NUMBER?", CONVERT, tos = convert((const char *) *sp, tos, g_sys.base, sp); \ - if (!tos) --sp) \ + XV(INTERNALS, "S>NUMBER?", \ + CONVERT, tos = convert((const char *) *sp, tos, g_sys.base, sp); \ + if (!tos) --sp) \ Y(CREATE, DUP; DUP; tos = parse(32, sp); \ create((const char *) *sp, tos, 0, ADDR_DOCREATE); \ COMMA(0); DROPn(2)) \ X("DOES>", DOES, DOES(ip); ip = (cell_t *) *rp; --rp) \ Y(IMMEDIATE, DOIMMEDIATE()) \ - X("'SYS", SYS, DUP; tos = (cell_t) &g_sys) \ + XV(INTERNALS, "'SYS", SYS, DUP; tos = (cell_t) &g_sys) \ Y(YIELD, PARK; return rp) \ X(":", COLON, DUP; DUP; tos = parse(32, sp); \ create((const char *) *sp, tos, SMUDGE, ADDR_DOCOLON); \ g_sys.state = -1; --sp; DROP) \ - Y(EVALUATE1, DUP; float *tfp = fp; \ + YV(INTERNALS, EVALUATE1, DUP; float *tfp = fp; \ sp = evaluate1(sp, &tfp); \ fp = tfp; w = *sp--; DROP; if (w) JMPW) \ Y(EXIT, ip = (cell_t *) *rp--) \ + Y(foo, DUP; tos = (cell_t) foo) \ X(";", SEMICOLON, COMMA(g_sys.DOEXIT_XT); UNSMUDGE(); g_sys.state = 0) diff --git a/ueforth/esp32/builtins.h b/ueforth/esp32/builtins.h index 3db6666..c81efb8 100644 --- a/ueforth/esp32/builtins.h +++ b/ueforth/esp32/builtins.h @@ -58,26 +58,26 @@ static cell_t ResizeFile(cell_t fd, cell_t size); FLOATING_POINT_LIST #define REQUIRED_MEMORY_SUPPORT \ - Y(MALLOC, SET malloc(n0)) \ - Y(SYSFREE, free(a0); DROP) \ - Y(REALLOC, SET realloc(a1, n0); NIP) \ - Y(heap_caps_malloc, SET heap_caps_malloc(n1, n0); NIP) \ - Y(heap_caps_free, heap_caps_free(a0); DROP) \ - Y(heap_caps_realloc, \ + YV(INTERNALS, MALLOC, SET malloc(n0)) \ + YV(INTERNALS, SYSFREE, free(a0); DROP) \ + YV(INTERNALS, REALLOC, SET realloc(a1, n0); NIP) \ + YV(INTERNALS, heap_caps_malloc, SET heap_caps_malloc(n1, n0); NIP) \ + YV(INTERNALS, heap_caps_free, heap_caps_free(a0); DROP) \ + YV(INTERNALS, heap_caps_realloc, \ tos = (cell_t) heap_caps_realloc(a2, n1, n0); NIPn(2)) #define REQUIRED_SYSTEM_SUPPORT \ X("MS-TICKS", MS_TICKS, PUSH millis()) \ - X("RAW-YIELD", RAW_YIELD, yield()) \ + XV(INTERNALS, "RAW-YIELD", RAW_YIELD, yield()) \ Y(TERMINATE, exit(n0)) #define REQUIRED_SERIAL_SUPPORT \ - X("Serial.begin", SERIAL_BEGIN, Serial.begin(tos); DROP) \ - X("Serial.end", SERIAL_END, Serial.end()) \ - X("Serial.available", SERIAL_AVAILABLE, PUSH Serial.available()) \ - X("Serial.readBytes", SERIAL_READ_BYTES, n0 = Serial.readBytes(b1, n0); NIP) \ - X("Serial.write", SERIAL_WRITE, n0 = Serial.write(b1, n0); NIP) \ - X("Serial.flush", SERIAL_FLUSH, Serial.flush()) + XV(SERIAL, "Serial.begin", SERIAL_BEGIN, Serial.begin(tos); DROP) \ + XV(SERIAL, "Serial.end", SERIAL_END, Serial.end()) \ + XV(SERIAL, "Serial.available", SERIAL_AVAILABLE, PUSH Serial.available()) \ + XV(SERIAL, "Serial.readBytes", SERIAL_READ_BYTES, n0 = Serial.readBytes(b1, n0); NIP) \ + XV(SERIAL, "Serial.write", SERIAL_WRITE, n0 = Serial.write(b1, n0); NIP) \ + XV(SERIAL, "Serial.flush", SERIAL_FLUSH, Serial.flush()) #define REQUIRED_ARDUINO_GPIO_SUPPORT \ Y(pinMode, pinMode(n1, n0); DROPn(2)) \ @@ -149,56 +149,56 @@ static cell_t ResizeFile(cell_t fd, cell_t size); # include "esp_partition.h" # endif # define OPTIONAL_SPI_FLASH_SUPPORT \ - Y(spi_flash_init, spi_flash_init()) \ - Y(spi_flash_get_chip_size, PUSH spi_flash_get_chip_size()) \ - Y(spi_flash_erase_sector, n0 = spi_flash_erase_sector(n0)) \ - Y(spi_flash_erase_range, n0 = spi_flash_erase_range(n1, n0); DROP) \ - Y(spi_flash_write, n0 = spi_flash_write(n2, a1, n0); NIPn(2)) \ - Y(spi_flash_write_encrypted, n0 = spi_flash_write_encrypted(n2, a1, n0); NIPn(2)) \ - Y(spi_flash_read, n0 = spi_flash_read(n2, a1, n0); NIPn(2)) \ - Y(spi_flash_read_encrypted, n0 = spi_flash_read_encrypted(n2, a1, n0); NIPn(2)) \ - Y(spi_flash_mmap, \ + YV(SPI_FLASH, spi_flash_init, spi_flash_init()) \ + YV(SPI_FLASH, spi_flash_get_chip_size, PUSH spi_flash_get_chip_size()) \ + YV(SPI_FLASH, spi_flash_erase_sector, n0 = spi_flash_erase_sector(n0)) \ + YV(SPI_FLASH, spi_flash_erase_range, n0 = spi_flash_erase_range(n1, n0); DROP) \ + YV(SPI_FLASH, spi_flash_write, n0 = spi_flash_write(n2, a1, n0); NIPn(2)) \ + YV(SPI_FLASH, spi_flash_write_encrypted, n0 = spi_flash_write_encrypted(n2, a1, n0); NIPn(2)) \ + YV(SPI_FLASH, spi_flash_read, n0 = spi_flash_read(n2, a1, n0); NIPn(2)) \ + YV(SPI_FLASH, spi_flash_read_encrypted, n0 = spi_flash_read_encrypted(n2, a1, n0); NIPn(2)) \ + YV(SPI_FLASH, spi_flash_mmap, \ n0 = spi_flash_mmap(n4, n3, (spi_flash_mmap_memory_t) n2, \ (const void **) a1, (spi_flash_mmap_handle_t *) a0); NIPn(4)) \ - Y(spi_flash_mmap_pages, \ + YV(SPI_FLASH, spi_flash_mmap_pages, \ n0 = spi_flash_mmap_pages((const int *) a4, n3, (spi_flash_mmap_memory_t) n2, \ (const void **) a1, (spi_flash_mmap_handle_t *) a0); NIPn(4)) \ - Y(spi_flash_munmap, spi_flash_munmap((spi_flash_mmap_handle_t) a0); DROP) \ - Y(spi_flash_mmap_dump, spi_flash_mmap_dump()) \ - Y(spi_flash_mmap_get_free_pages, \ + YV(SPI_FLASH, spi_flash_munmap, spi_flash_munmap((spi_flash_mmap_handle_t) a0); DROP) \ + YV(SPI_FLASH, spi_flash_mmap_dump, spi_flash_mmap_dump()) \ + YV(SPI_FLASH, spi_flash_mmap_get_free_pages, \ n0 = spi_flash_mmap_get_free_pages((spi_flash_mmap_memory_t) n0)) \ - Y(spi_flash_cache2phys, n0 = spi_flash_cache2phys(a0)) \ - Y(spi_flash_phys2cache, \ + YV(SPI_FLASH, spi_flash_cache2phys, n0 = spi_flash_cache2phys(a0)) \ + YV(SPI_FLASH, spi_flash_phys2cache, \ n0 = (cell_t) spi_flash_phys2cache(n1, (spi_flash_mmap_memory_t) n0); NIP) \ - Y(spi_flash_cache_enabled, PUSH spi_flash_cache_enabled()) \ - Y(esp_partition_find, \ + YV(SPI_FLASH, spi_flash_cache_enabled, PUSH spi_flash_cache_enabled()) \ + YV(SPI_FLASH, esp_partition_find, \ n0 = (cell_t) esp_partition_find((esp_partition_type_t) n2, \ (esp_partition_subtype_t) n1, c0); NIPn(2)) \ - Y(esp_partition_find_first, \ + YV(SPI_FLASH, esp_partition_find_first, \ n0 = (cell_t) esp_partition_find_first((esp_partition_type_t) n2, \ (esp_partition_subtype_t) n1, c0); NIPn(2)) \ - Y(esp_partition_t_size, PUSH sizeof(esp_partition_t)) \ - Y(esp_partition_get, \ + YV(SPI_FLASH, esp_partition_t_size, PUSH sizeof(esp_partition_t)) \ + YV(SPI_FLASH, esp_partition_get, \ n0 = (cell_t) esp_partition_get((esp_partition_iterator_t) a0)) \ - Y(esp_partition_next, \ + YV(SPI_FLASH, esp_partition_next, \ n0 = (cell_t) esp_partition_next((esp_partition_iterator_t) a0)) \ - Y(esp_partition_iterator_release, \ + YV(SPI_FLASH, esp_partition_iterator_release, \ esp_partition_iterator_release((esp_partition_iterator_t) a0); DROP) \ - Y(esp_partition_verify, n0 = (cell_t) esp_partition_verify((esp_partition_t *) a0)) \ - Y(esp_partition_read, \ + YV(SPI_FLASH, esp_partition_verify, n0 = (cell_t) esp_partition_verify((esp_partition_t *) a0)) \ + YV(SPI_FLASH, esp_partition_read, \ n0 = esp_partition_read((const esp_partition_t *) a3, n2, a1, n0); NIPn(3)) \ - Y(esp_partition_write, \ + YV(SPI_FLASH, esp_partition_write, \ n0 = esp_partition_write((const esp_partition_t *) a3, n2, a1, n0); NIPn(3)) \ - Y(esp_partition_erase_range, \ + YV(SPI_FLASH, esp_partition_erase_range, \ n0 = esp_partition_erase_range((const esp_partition_t *) a2, n1, n0); NIPn(2)) \ - Y(esp_partition_mmap, \ + YV(SPI_FLASH, esp_partition_mmap, \ n0 = esp_partition_mmap((const esp_partition_t *) a5, n4, n3, \ (spi_flash_mmap_memory_t) n2, \ (const void **) a1, \ (spi_flash_mmap_handle_t *) a0); NIPn(5)) \ - Y(esp_partition_get_sha256, \ + YV(SPI_FLASH, esp_partition_get_sha256, \ n0 = esp_partition_get_sha256((const esp_partition_t *) a1, b0); NIP) \ - Y(esp_partition_check_identity, \ + YV(SPI_FLASH, esp_partition_check_identity, \ n0 = esp_partition_check_identity((const esp_partition_t *) a1, \ (const esp_partition_t *) a0); NIP) #endif @@ -212,12 +212,12 @@ static cell_t ResizeFile(cell_t fd, cell_t size); # include "SPIFFS.h" # endif # define OPTIONAL_SPIFFS_SUPPORT \ - X("SPIFFS.begin", SPIFFS_BEGIN, \ + XV(SPIFFS, "SPIFFS.begin", SPIFFS_BEGIN, \ tos = SPIFFS.begin(n2, c1, n0); NIPn(2)) \ - X("SPIFFS.end", SPIFFS_END, SPIFFS.end()) \ - X("SPIFFS.format", SPIFFS_FORMAT, PUSH SPIFFS.format()) \ - X("SPIFFS.totalBytes", SPIFFS_TOTAL_BYTES, PUSH SPIFFS.totalBytes()) \ - X("SPIFFS.usedBytes", SPIFFS_USED_BYTES, PUSH SPIFFS.usedBytes()) + XV(SPIFFS, "SPIFFS.end", SPIFFS_END, SPIFFS.end()) \ + XV(SPIFFS, "SPIFFS.format", SPIFFS_FORMAT, PUSH SPIFFS.format()) \ + XV(SPIFFS, "SPIFFS.totalBytes", SPIFFS_TOTAL_BYTES, PUSH SPIFFS.totalBytes()) \ + XV(SPIFFS, "SPIFFS.usedBytes", SPIFFS_USED_BYTES, PUSH SPIFFS.usedBytes()) #endif #ifndef ENABLE_FREERTOS_SUPPORT @@ -228,10 +228,10 @@ static cell_t ResizeFile(cell_t fd, cell_t size); # include "freertos/task.h" # endif # define OPTIONAL_FREERTOS_SUPPORT \ - Y(vTaskDelete, vTaskDelete((TaskHandle_t) n0); DROP) \ - Y(xTaskCreatePinnedToCore, n0 = xTaskCreatePinnedToCore((TaskFunction_t) a6, \ + YV(RTOS, vTaskDelete, vTaskDelete((TaskHandle_t) n0); DROP) \ + YV(RTOS, xTaskCreatePinnedToCore, n0 = xTaskCreatePinnedToCore((TaskFunction_t) a6, \ c5, n4, a3, (UBaseType_t) n2, (TaskHandle_t *) a1, (BaseType_t) n0); NIPn(6)) \ - Y(xPortGetCoreID, PUSH xPortGetCoreID()) + YV(RTOS, xPortGetCoreID, PUSH xPortGetCoreID()) #endif #ifndef ENABLE_INTERRUPTS_SUPPORT @@ -246,34 +246,34 @@ static cell_t GpioIsrHandlerAdd(cell_t pin, cell_t xt, cell_t arg); static cell_t TimerIsrRegister(cell_t group, cell_t timer, cell_t xt, cell_t arg, cell_t flags, void *ret); # endif # define OPTIONAL_INTERRUPTS_SUPPORT \ - Y(gpio_config, n0 = gpio_config((const gpio_config_t *) a0)) \ - Y(gpio_reset_pin, n0 = gpio_reset_pin((gpio_num_t) n0)) \ - Y(gpio_set_intr_type, n0 = gpio_set_intr_type((gpio_num_t) n1, (gpio_int_type_t) n0); NIP) \ - Y(gpio_intr_enable, n0 = gpio_intr_enable((gpio_num_t) n0)) \ - Y(gpio_intr_disable, n0 = gpio_intr_disable((gpio_num_t) n0)) \ - Y(gpio_set_level, n0 = gpio_set_level((gpio_num_t) n1, n0); NIP) \ - Y(gpio_get_level, n0 = gpio_get_level((gpio_num_t) n0)) \ - Y(gpio_set_direction, n0 = gpio_set_direction((gpio_num_t) n1, (gpio_mode_t) n0); NIP) \ - Y(gpio_set_pull_mode, n0 = gpio_set_pull_mode((gpio_num_t) n1, (gpio_pull_mode_t) n0); NIP) \ - Y(gpio_wakeup_enable, n0 = gpio_wakeup_enable((gpio_num_t) n1, (gpio_int_type_t) n0); NIP) \ - Y(gpio_wakeup_disable, n0 = gpio_wakeup_disable((gpio_num_t) n0)) \ - Y(gpio_pullup_en, n0 = gpio_pullup_en((gpio_num_t) n0)) \ - Y(gpio_pullup_dis, n0 = gpio_pullup_dis((gpio_num_t) n0)) \ - Y(gpio_pulldown_en, n0 = gpio_pulldown_en((gpio_num_t) n0)) \ - Y(gpio_pulldown_dis, n0 = gpio_pulldown_dis((gpio_num_t) n0)) \ - Y(gpio_hold_en, n0 = gpio_hold_en((gpio_num_t) n0)) \ - Y(gpio_hold_dis, n0 = gpio_hold_dis((gpio_num_t) n0)) \ - Y(gpio_deep_sleep_hold_en, gpio_deep_sleep_hold_en()) \ - Y(gpio_deep_sleep_hold_dis, gpio_deep_sleep_hold_dis()) \ - Y(gpio_install_isr_service, n0 = gpio_install_isr_service(n0)) \ - Y(gpio_uninstall_isr_service, gpio_uninstall_isr_service()) \ - Y(gpio_isr_handler_add, n0 = GpioIsrHandlerAdd(n2, n1, n0); NIPn(2)) \ - Y(gpio_isr_handler_remove, n0 = gpio_isr_handler_remove((gpio_num_t) n0)) \ - Y(gpio_set_drive_capability, n0 = gpio_set_drive_capability((gpio_num_t) n1, (gpio_drive_cap_t) n0); NIP) \ - Y(gpio_get_drive_capability, n0 = gpio_get_drive_capability((gpio_num_t) n1, (gpio_drive_cap_t *) a0); NIP) \ - Y(esp_intr_alloc, n0 = EspIntrAlloc(n4, n3, n2, n1, a0); NIPn(4)) \ - Y(esp_intr_free, n0 = esp_intr_free((intr_handle_t) n0)) \ - Y(timer_isr_register, n0 = TimerIsrRegister(n5, n4, n3, n2, n1, a0); NIPn(5)) + YV(INTERRUPTS, gpio_config, n0 = gpio_config((const gpio_config_t *) a0)) \ + YV(INTERRUPTS, gpio_reset_pin, n0 = gpio_reset_pin((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_set_intr_type, n0 = gpio_set_intr_type((gpio_num_t) n1, (gpio_int_type_t) n0); NIP) \ + YV(INTERRUPTS, gpio_intr_enable, n0 = gpio_intr_enable((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_intr_disable, n0 = gpio_intr_disable((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_set_level, n0 = gpio_set_level((gpio_num_t) n1, n0); NIP) \ + YV(INTERRUPTS, gpio_get_level, n0 = gpio_get_level((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_set_direction, n0 = gpio_set_direction((gpio_num_t) n1, (gpio_mode_t) n0); NIP) \ + YV(INTERRUPTS, gpio_set_pull_mode, n0 = gpio_set_pull_mode((gpio_num_t) n1, (gpio_pull_mode_t) n0); NIP) \ + YV(INTERRUPTS, gpio_wakeup_enable, n0 = gpio_wakeup_enable((gpio_num_t) n1, (gpio_int_type_t) n0); NIP) \ + YV(INTERRUPTS, gpio_wakeup_disable, n0 = gpio_wakeup_disable((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_pullup_en, n0 = gpio_pullup_en((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_pullup_dis, n0 = gpio_pullup_dis((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_pulldown_en, n0 = gpio_pulldown_en((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_pulldown_dis, n0 = gpio_pulldown_dis((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_hold_en, n0 = gpio_hold_en((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_hold_dis, n0 = gpio_hold_dis((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_deep_sleep_hold_en, gpio_deep_sleep_hold_en()) \ + YV(INTERRUPTS, gpio_deep_sleep_hold_dis, gpio_deep_sleep_hold_dis()) \ + YV(INTERRUPTS, gpio_install_isr_service, n0 = gpio_install_isr_service(n0)) \ + YV(INTERRUPTS, gpio_uninstall_isr_service, gpio_uninstall_isr_service()) \ + YV(INTERRUPTS, gpio_isr_handler_add, n0 = GpioIsrHandlerAdd(n2, n1, n0); NIPn(2)) \ + YV(INTERRUPTS, gpio_isr_handler_remove, n0 = gpio_isr_handler_remove((gpio_num_t) n0)) \ + YV(INTERRUPTS, gpio_set_drive_capability, n0 = gpio_set_drive_capability((gpio_num_t) n1, (gpio_drive_cap_t) n0); NIP) \ + YV(INTERRUPTS, gpio_get_drive_capability, n0 = gpio_get_drive_capability((gpio_num_t) n1, (gpio_drive_cap_t *) a0); NIP) \ + YV(INTERRUPTS, esp_intr_alloc, n0 = EspIntrAlloc(n4, n3, n2, n1, a0); NIPn(4)) \ + YV(INTERRUPTS, esp_intr_free, n0 = esp_intr_free((intr_handle_t) n0)) \ + YV(INTERRUPTS, timer_isr_register, n0 = TimerIsrRegister(n5, n4, n3, n2, n1, a0); NIPn(5)) #endif #ifndef ENABLE_RMT_SUPPORT @@ -283,57 +283,57 @@ static cell_t TimerIsrRegister(cell_t group, cell_t timer, cell_t xt, cell_t arg # include "driver/rmt.h" # endif # define OPTIONAL_RMT_SUPPORT \ - Y(rmt_set_clk_div, n0 = rmt_set_clk_div((rmt_channel_t) n1, n0); NIP) \ - Y(rmt_get_clk_div, n0 = rmt_get_clk_div((rmt_channel_t) n1, b0); NIP) \ - Y(rmt_set_rx_idle_thresh, n0 = rmt_set_rx_idle_thresh((rmt_channel_t) n1, n0); NIP) \ - Y(rmt_get_rx_idle_thresh, \ + YV(RMT, rmt_set_clk_div, n0 = rmt_set_clk_div((rmt_channel_t) n1, n0); NIP) \ + YV(RMT, rmt_get_clk_div, n0 = rmt_get_clk_div((rmt_channel_t) n1, b0); NIP) \ + YV(RMT, rmt_set_rx_idle_thresh, n0 = rmt_set_rx_idle_thresh((rmt_channel_t) n1, n0); NIP) \ + YV(RMT, rmt_get_rx_idle_thresh, \ n0 = rmt_get_rx_idle_thresh((rmt_channel_t) n1, (uint16_t *) a0); NIP) \ - Y(rmt_set_mem_block_num, n0 = rmt_set_mem_block_num((rmt_channel_t) n1, n0); NIP) \ - Y(rmt_get_mem_block_num, n0 = rmt_get_mem_block_num((rmt_channel_t) n1, b0); NIP) \ - Y(rmt_set_tx_carrier, n0 = rmt_set_tx_carrier((rmt_channel_t) n4, n3, n2, n1, \ + YV(RMT, rmt_set_mem_block_num, n0 = rmt_set_mem_block_num((rmt_channel_t) n1, n0); NIP) \ + YV(RMT, rmt_get_mem_block_num, n0 = rmt_get_mem_block_num((rmt_channel_t) n1, b0); NIP) \ + YV(RMT, rmt_set_tx_carrier, n0 = rmt_set_tx_carrier((rmt_channel_t) n4, n3, n2, n1, \ (rmt_carrier_level_t) n0); NIPn(4)) \ - Y(rmt_set_mem_pd, n0 = rmt_set_mem_pd((rmt_channel_t) n1, n0); NIP) \ - Y(rmt_get_mem_pd, n0 = rmt_get_mem_pd((rmt_channel_t) n1, (bool *) a0); NIP) \ - Y(rmt_tx_start, n0 = rmt_tx_start((rmt_channel_t) n1, n0); NIP) \ - Y(rmt_tx_stop, n0 = rmt_tx_stop((rmt_channel_t) n0)) \ - Y(rmt_rx_start, n0 = rmt_rx_start((rmt_channel_t) n1, n0); NIP) \ - Y(rmt_rx_stop, n0 = rmt_rx_stop((rmt_channel_t) n0)) \ - Y(rmt_tx_memory_reset, n0 = rmt_tx_memory_reset((rmt_channel_t) n0)) \ - Y(rmt_rx_memory_reset, n0 = rmt_rx_memory_reset((rmt_channel_t) n0)) \ - Y(rmt_set_memory_owner, n0 = rmt_set_memory_owner((rmt_channel_t) n1, (rmt_mem_owner_t) n0); NIP) \ - Y(rmt_get_memory_owner, n0 = rmt_get_memory_owner((rmt_channel_t) n1, (rmt_mem_owner_t *) a0); NIP) \ - Y(rmt_set_tx_loop_mode, n0 = rmt_set_tx_loop_mode((rmt_channel_t) n1, n0); NIP) \ - Y(rmt_get_tx_loop_mode, n0 = rmt_get_tx_loop_mode((rmt_channel_t) n1, (bool *) a0); NIP) \ - Y(rmt_set_rx_filter, n0 = rmt_set_rx_filter((rmt_channel_t) n2, n1, n0); NIPn(2)) \ - Y(rmt_set_source_clk, n0 = rmt_set_source_clk((rmt_channel_t) n1, (rmt_source_clk_t) n0); NIP) \ - Y(rmt_get_source_clk, n0 = rmt_get_source_clk((rmt_channel_t) n1, (rmt_source_clk_t * ) a0); NIP) \ - Y(rmt_set_idle_level, n0 = rmt_set_idle_level((rmt_channel_t) n2, n1, \ + YV(RMT, rmt_set_mem_pd, n0 = rmt_set_mem_pd((rmt_channel_t) n1, n0); NIP) \ + YV(RMT, rmt_get_mem_pd, n0 = rmt_get_mem_pd((rmt_channel_t) n1, (bool *) a0); NIP) \ + YV(RMT, rmt_tx_start, n0 = rmt_tx_start((rmt_channel_t) n1, n0); NIP) \ + YV(RMT, rmt_tx_stop, n0 = rmt_tx_stop((rmt_channel_t) n0)) \ + YV(RMT, rmt_rx_start, n0 = rmt_rx_start((rmt_channel_t) n1, n0); NIP) \ + YV(RMT, rmt_rx_stop, n0 = rmt_rx_stop((rmt_channel_t) n0)) \ + YV(RMT, rmt_tx_memory_reset, n0 = rmt_tx_memory_reset((rmt_channel_t) n0)) \ + YV(RMT, rmt_rx_memory_reset, n0 = rmt_rx_memory_reset((rmt_channel_t) n0)) \ + YV(RMT, rmt_set_memory_owner, n0 = rmt_set_memory_owner((rmt_channel_t) n1, (rmt_mem_owner_t) n0); NIP) \ + YV(RMT, rmt_get_memory_owner, n0 = rmt_get_memory_owner((rmt_channel_t) n1, (rmt_mem_owner_t *) a0); NIP) \ + YV(RMT, rmt_set_tx_loop_mode, n0 = rmt_set_tx_loop_mode((rmt_channel_t) n1, n0); NIP) \ + YV(RMT, rmt_get_tx_loop_mode, n0 = rmt_get_tx_loop_mode((rmt_channel_t) n1, (bool *) a0); NIP) \ + YV(RMT, rmt_set_rx_filter, n0 = rmt_set_rx_filter((rmt_channel_t) n2, n1, n0); NIPn(2)) \ + YV(RMT, rmt_set_source_clk, n0 = rmt_set_source_clk((rmt_channel_t) n1, (rmt_source_clk_t) n0); NIP) \ + YV(RMT, rmt_get_source_clk, n0 = rmt_get_source_clk((rmt_channel_t) n1, (rmt_source_clk_t * ) a0); NIP) \ + YV(RMT, rmt_set_idle_level, n0 = rmt_set_idle_level((rmt_channel_t) n2, n1, \ (rmt_idle_level_t) n0); NIPn(2)) \ - Y(rmt_get_idle_level, n0 = rmt_get_idle_level((rmt_channel_t) n2, \ + YV(RMT, rmt_get_idle_level, n0 = rmt_get_idle_level((rmt_channel_t) n2, \ (bool *) a1, (rmt_idle_level_t *) a0); NIPn(2)) \ - Y(rmt_get_status, n0 = rmt_get_status((rmt_channel_t) n1, (uint32_t *) a0); NIP) \ - Y(rmt_set_rx_intr_en, n0 = rmt_set_rx_intr_en((rmt_channel_t) n1, n0); NIP) \ - Y(rmt_set_err_intr_en, n0 = rmt_set_err_intr_en((rmt_channel_t) n1, (rmt_mode_t) n0); NIP) \ - Y(rmt_set_tx_intr_en, n0 = rmt_set_tx_intr_en((rmt_channel_t) n1, n0); NIP) \ - Y(rmt_set_tx_thr_intr_en, n0 = rmt_set_tx_thr_intr_en((rmt_channel_t) n2, n1, n0); NIPn(2)) \ - Y(rmt_set_gpio, n0 = rmt_set_gpio((rmt_channel_t) n3, (rmt_mode_t) n2, (gpio_num_t) n1, n0); NIPn(3)) \ - Y(rmt_config, n0 = rmt_config((const rmt_config_t *) a0)) \ - Y(rmt_isr_register, n0 = rmt_isr_register((void (*)(void*)) a3, a2, n1, \ + YV(RMT, rmt_get_status, n0 = rmt_get_status((rmt_channel_t) n1, (uint32_t *) a0); NIP) \ + YV(RMT, rmt_set_rx_intr_en, n0 = rmt_set_rx_intr_en((rmt_channel_t) n1, n0); NIP) \ + YV(RMT, rmt_set_err_intr_en, n0 = rmt_set_err_intr_en((rmt_channel_t) n1, (rmt_mode_t) n0); NIP) \ + YV(RMT, rmt_set_tx_intr_en, n0 = rmt_set_tx_intr_en((rmt_channel_t) n1, n0); NIP) \ + YV(RMT, rmt_set_tx_thr_intr_en, n0 = rmt_set_tx_thr_intr_en((rmt_channel_t) n2, n1, n0); NIPn(2)) \ + YV(RMT, rmt_set_gpio, n0 = rmt_set_gpio((rmt_channel_t) n3, (rmt_mode_t) n2, (gpio_num_t) n1, n0); NIPn(3)) \ + YV(RMT, rmt_config, n0 = rmt_config((const rmt_config_t *) a0)) \ + YV(RMT, rmt_isr_register, n0 = rmt_isr_register((void (*)(void*)) a3, a2, n1, \ (rmt_isr_handle_t *) a0); NIPn(3)) \ - Y(rmt_isr_deregister, n0 = rmt_isr_deregister((rmt_isr_handle_t) n0)) \ - Y(rmt_fill_tx_items, n0 = rmt_fill_tx_items((rmt_channel_t) n3, \ + YV(RMT, rmt_isr_deregister, n0 = rmt_isr_deregister((rmt_isr_handle_t) n0)) \ + YV(RMT, rmt_fill_tx_items, n0 = rmt_fill_tx_items((rmt_channel_t) n3, \ (rmt_item32_t *) a2, n1, n0); NIPn(3)) \ - Y(rmt_driver_install, n0 = rmt_driver_install((rmt_channel_t) n2, n1, n0); NIPn(2)) \ - Y(rmt_driver_uinstall, n0 = rmt_driver_uninstall((rmt_channel_t) n0)) \ - Y(rmt_get_channel_status, n0 = rmt_get_channel_status((rmt_channel_status_result_t *) a0)) \ - Y(rmt_get_counter_clock, n0 = rmt_get_counter_clock((rmt_channel_t) n1, (uint32_t *) a0); NIP) \ - Y(rmt_write_items, n0 = rmt_write_items((rmt_channel_t) n3, (rmt_item32_t *) a2, n1, n0); NIPn(3)) \ - Y(rmt_wait_tx_done, n0 = rmt_wait_tx_done((rmt_channel_t) n1, n0); NIP) \ - Y(rmt_get_ringbuf_handle, n0 = rmt_get_ringbuf_handle((rmt_channel_t) n1, (RingbufHandle_t *) a0); NIP) \ - Y(rmt_translator_init, n0 = rmt_translator_init((rmt_channel_t) n1, (sample_to_rmt_t) n0); NIP) \ - Y(rmt_translator_set_context, n0 = rmt_translator_set_context((rmt_channel_t) n1, a0); NIP) \ - Y(rmt_translator_get_context, n0 = rmt_translator_get_context((const size_t *) a1, (void **) a0); NIP) \ - Y(rmt_write_sample, n0 = rmt_write_sample((rmt_channel_t) n3, b2, n1, n0); NIPn(3)) + YV(RMT, rmt_driver_install, n0 = rmt_driver_install((rmt_channel_t) n2, n1, n0); NIPn(2)) \ + YV(RMT, rmt_driver_uinstall, n0 = rmt_driver_uninstall((rmt_channel_t) n0)) \ + YV(RMT, rmt_get_channel_status, n0 = rmt_get_channel_status((rmt_channel_status_result_t *) a0)) \ + YV(RMT, rmt_get_counter_clock, n0 = rmt_get_counter_clock((rmt_channel_t) n1, (uint32_t *) a0); NIP) \ + YV(RMT, rmt_write_items, n0 = rmt_write_items((rmt_channel_t) n3, (rmt_item32_t *) a2, n1, n0); NIPn(3)) \ + YV(RMT, rmt_wait_tx_done, n0 = rmt_wait_tx_done((rmt_channel_t) n1, n0); NIP) \ + YV(RMT, rmt_get_ringbuf_handle, n0 = rmt_get_ringbuf_handle((rmt_channel_t) n1, (RingbufHandle_t *) a0); NIP) \ + YV(RMT, rmt_translator_init, n0 = rmt_translator_init((rmt_channel_t) n1, (sample_to_rmt_t) n0); NIP) \ + YV(RMT, rmt_translator_set_context, n0 = rmt_translator_set_context((rmt_channel_t) n1, a0); NIP) \ + YV(RMT, rmt_translator_get_context, n0 = rmt_translator_get_context((const size_t *) a1, (void **) a0); NIP) \ + YV(RMT, rmt_write_sample, n0 = rmt_write_sample((rmt_channel_t) n3, b2, n1, n0); NIPn(3)) #endif #ifndef ENABLE_CAMERA_SUPPORT @@ -343,11 +343,11 @@ static cell_t TimerIsrRegister(cell_t group, cell_t timer, cell_t xt, cell_t arg # include "esp_camera.h" # endif # define OPTIONAL_CAMERA_SUPPORT \ - Y(esp_camera_init, n0 = esp_camera_init((camera_config_t *) a0)) \ - Y(esp_camera_deinit, PUSH esp_camera_deinit()) \ - Y(esp_camera_fb_get, PUSH esp_camera_fb_get()) \ - Y(esp_camera_fb_return, esp_camera_fb_return((camera_fb_t *) a0); DROP) \ - Y(esp_camera_sensor_get, PUSH esp_camera_sensor_get()) + YV(CAMERA, esp_camera_init, n0 = esp_camera_init((camera_config_t *) a0)) \ + YV(CAMERA, esp_camera_deinit, PUSH esp_camera_deinit()) \ + YV(CAMERA, esp_camera_fb_get, PUSH esp_camera_fb_get()) \ + YV(CAMERA, esp_camera_fb_return, esp_camera_fb_return((camera_fb_t *) a0); DROP) \ + YV(CAMERA, esp_camera_sensor_get, PUSH esp_camera_sensor_get()) #endif #ifndef ENABLE_SOCKETS_SUPPORT @@ -363,15 +363,15 @@ static cell_t TimerIsrRegister(cell_t group, cell_t timer, cell_t xt, cell_t arg # include # endif # define OPTIONAL_SOCKETS_SUPPORT \ - Y(socket, n0 = socket(n2, n1, n0); NIPn(2)) \ - Y(setsockopt, n0 = setsockopt(n4, n3, n2, a1, n0); NIPn(4)) \ - Y(bind, n0 = bind(n2, (struct sockaddr *) a1, n0); NIPn(2)) \ - Y(listen, n0 = listen(n1, n0); NIP) \ - Y(connect, n0 = connect(n2, (struct sockaddr *) a1, n0); NIPn(2)) \ - Y(sockaccept, n0 = accept(n2, (struct sockaddr *) a1, (socklen_t *) a0); NIPn(2)) \ - Y(select, n0 = select(n4, (fd_set *) a3, (fd_set *) a2, (fd_set *) a1, (struct timeval *) a0); NIPn(4)) \ - Y(poll, n0 = poll((struct pollfd *) a2, (nfds_t) n1, n0); NIPn(2)) \ - Y(errno, PUSH errno) + YV(SOCKETS, socket, n0 = socket(n2, n1, n0); NIPn(2)) \ + YV(SOCKETS, setsockopt, n0 = setsockopt(n4, n3, n2, a1, n0); NIPn(4)) \ + YV(SOCKETS, bind, n0 = bind(n2, (struct sockaddr *) a1, n0); NIPn(2)) \ + YV(SOCKETS, listen, n0 = listen(n1, n0); NIP) \ + YV(SOCKETS, connect, n0 = connect(n2, (struct sockaddr *) a1, n0); NIPn(2)) \ + YV(SOCKETS, sockaccept, n0 = accept(n2, (struct sockaddr *) a1, (socklen_t *) a0); NIPn(2)) \ + YV(SOCKETS, select, n0 = select(n4, (fd_set *) a3, (fd_set *) a2, (fd_set *) a1, (struct timeval *) a0); NIPn(4)) \ + YV(SOCKETS, poll, n0 = poll((struct pollfd *) a2, (nfds_t) n1, n0); NIPn(2)) \ + YV(SOCKETS, errno, PUSH errno) #endif #ifndef ENABLE_SD_SUPPORT @@ -381,15 +381,15 @@ static cell_t TimerIsrRegister(cell_t group, cell_t timer, cell_t xt, cell_t arg # include "SD.h" # endif # define OPTIONAL_SD_SUPPORT \ - X("SD.begin", SD_BEGIN, PUSH SD.begin()) \ - X("SD.beginFull", SD_BEGIN_FULL, \ + XV(SD, "SD.begin", SD_BEGIN, PUSH SD.begin()) \ + XV(SD, "SD.beginFull", SD_BEGIN_FULL, \ tos = SD.begin(n5, *(SPIClass*)a4, n3, c2, n1, n0); NIPn(5)) \ - X("SD.beginDefaults", SD_BEGIN_DEFAULTS, \ + XV(SD, "SD.beginDefaults", SD_BEGIN_DEFAULTS, \ PUSH SS; PUSH &SPI; PUSH 4000000; PUSH "/sd"; PUSH 5; PUSH false) \ - X("SD.end", SD_END, SD.end()) \ - X("SD.cardType", SD_CARD_TYPE, PUSH SD.cardType()) \ - X("SD.totalBytes", SD_TOTAL_BYTES, PUSH SD.totalBytes()) \ - X("SD.usedBytes", SD_USED_BYTES, PUSH SD.usedBytes()) + XV(SD, "SD.end", SD_END, SD.end()) \ + XV(SD, "SD.cardType", SD_CARD_TYPE, PUSH SD.cardType()) \ + XV(SD, "SD.totalBytes", SD_TOTAL_BYTES, PUSH SD.totalBytes()) \ + XV(SD, "SD.usedBytes", SD_USED_BYTES, PUSH SD.usedBytes()) #endif #ifndef ENABLE_SD_MMC_SUPPORT @@ -399,14 +399,14 @@ static cell_t TimerIsrRegister(cell_t group, cell_t timer, cell_t xt, cell_t arg # include "SD_MMC.h" # endif # define OPTIONAL_SD_MMC_SUPPORT \ - X("SD_MMC.begin", SD_MMC_BEGIN, PUSH SD_MMC.begin()) \ - X("SD_MMC.beginFull", SD_MMC_BEGIN_FULL, tos = SD_MMC.begin(c2, n1, n0); NIPn(2)) \ - X("SD_MMC.beginDefaults", SD_MMC_BEGIN_DEFAULTS, \ + XV(SD_MMC, "SD_MMC.begin", SD_MMC_BEGIN, PUSH SD_MMC.begin()) \ + XV(SD_MMC, "SD_MMC.beginFull", SD_MMC_BEGIN_FULL, tos = SD_MMC.begin(c2, n1, n0); NIPn(2)) \ + XV(SD_MMC, "SD_MMC.beginDefaults", SD_MMC_BEGIN_DEFAULTS, \ PUSH "/sdcard"; PUSH false; PUSH false) \ - X("SD_MMC.end", SD_MMC_END, SD_MMC.end()) \ - X("SD_MMC.cardType", SD_MMC_CARD_TYPE, PUSH SD_MMC.cardType()) \ - X("SD_MMC.totalBytes", SD_MMC_TOTAL_BYTES, PUSH SD_MMC.totalBytes()) \ - X("SD_MMC.usedBytes", SD_MMC_USED_BYTES, PUSH SD_MMC.usedBytes()) + XV(SD_MMC, "SD_MMC.end", SD_MMC_END, SD_MMC.end()) \ + XV(SD_MMC, "SD_MMC.cardType", SD_MMC_CARD_TYPE, PUSH SD_MMC.cardType()) \ + XV(SD_MMC, "SD_MMC.totalBytes", SD_MMC_TOTAL_BYTES, PUSH SD_MMC.totalBytes()) \ + XV(SD_MMC, "SD_MMC.usedBytes", SD_MMC_USED_BYTES, PUSH SD_MMC.usedBytes()) #endif #ifndef ENABLE_I2C_SUPPORT @@ -416,19 +416,19 @@ static cell_t TimerIsrRegister(cell_t group, cell_t timer, cell_t xt, cell_t arg # include # endif # define OPTIONAL_I2C_SUPPORT \ - X("Wire.begin", WIRE_BEGIN, n0 = Wire.begin(n1, n0); NIP) \ - X("Wire.setClock", WIRE_SET_CLOCK, Wire.setClock(n0); DROP) \ - X("Wire.getClock", WIRE_GET_CLOCK, PUSH Wire.getClock()) \ - X("Wire.setTimeout", WIRE_SET_TIMEOUT, Wire.setTimeout(n0); DROP) \ - X("Wire.getTimeout", WIRE_GET_TIMEOUT, PUSH Wire.getTimeout()) \ - X("Wire.beginTransmission", WIRE_BEGIN_TRANSMISSION, Wire.beginTransmission(n0); DROP) \ - X("Wire.endTransmission", WIRE_END_TRANSMISSION, SET Wire.endTransmission(n0)) \ - X("Wire.requestFrom", WIRE_REQUEST_FROM, n0 = Wire.requestFrom(n2, n1, n0); NIPn(2)) \ - X("Wire.write", WIRE_WRITE, n0 = Wire.write(b1, n0); NIP) \ - X("Wire.available", WIRE_AVAILABLE, PUSH Wire.available()) \ - X("Wire.read", WIRE_READ, PUSH Wire.read()) \ - X("Wire.peek", WIRE_PEEK, PUSH Wire.peek()) \ - X("Wire.flush", WIRE_FLUSH, Wire.flush()) + XV(WIRE, "Wire.begin", WIRE_BEGIN, n0 = Wire.begin(n1, n0); NIP) \ + XV(WIRE, "Wire.setClock", WIRE_SET_CLOCK, Wire.setClock(n0); DROP) \ + XV(WIRE, "Wire.getClock", WIRE_GET_CLOCK, PUSH Wire.getClock()) \ + XV(WIRE, "Wire.setTimeout", WIRE_SET_TIMEOUT, Wire.setTimeout(n0); DROP) \ + XV(WIRE, "Wire.getTimeout", WIRE_GET_TIMEOUT, PUSH Wire.getTimeout()) \ + XV(WIRE, "Wire.beginTransmission", WIRE_BEGIN_TRANSMISSION, Wire.beginTransmission(n0); DROP) \ + XV(WIRE, "Wire.endTransmission", WIRE_END_TRANSMISSION, SET Wire.endTransmission(n0)) \ + XV(WIRE, "Wire.requestFrom", WIRE_REQUEST_FROM, n0 = Wire.requestFrom(n2, n1, n0); NIPn(2)) \ + XV(WIRE, "Wire.write", WIRE_WRITE, n0 = Wire.write(b1, n0); NIP) \ + XV(WIRE, "Wire.available", WIRE_AVAILABLE, PUSH Wire.available()) \ + XV(WIRE, "Wire.read", WIRE_READ, PUSH Wire.read()) \ + XV(WIRE, "Wire.peek", WIRE_PEEK, PUSH Wire.peek()) \ + XV(WIRE, "Wire.flush", WIRE_FLUSH, Wire.flush()) #endif #ifndef ENABLE_SERIAL_BLUETOOTH_SUPPORT @@ -440,26 +440,26 @@ static cell_t TimerIsrRegister(cell_t group, cell_t timer, cell_t xt, cell_t arg # define bt0 ((BluetoothSerial *) a0) # endif # define OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \ - X("SerialBT.new", SERIALBT_NEW, PUSH new BluetoothSerial()) \ - X("SerialBT.delete", SERIALBT_DELETE, delete bt0; DROP) \ - X("SerialBT.begin", SERIALBT_BEGIN, n0 = bt0->begin(c2, n1); NIPn(2)) \ - X("SerialBT.end", SERIALBT_END, bt0->end(); DROP) \ - X("SerialBT.available", SERIALBT_AVAILABLE, n0 = bt0->available()) \ - X("SerialBT.readBytes", SERIALBT_READ_BYTES, n0 = bt0->readBytes(b2, n1); NIPn(2)) \ - X("SerialBT.write", SERIALBT_WRITE, n0 = bt0->write(b2, n1); NIPn(2)) \ - X("SerialBT.flush", SERIALBT_FLUSH, bt0->flush(); DROP) \ - X("SerialBT.hasClient", SERIALBT_HAS_CLIENT, n0 = bt0->hasClient()) \ - X("SerialBT.enableSSP", SERIALBT_ENABLE_SSP, bt0->enableSSP(); DROP) \ - X("SerialBT.setPin", SERIALBT_SET_PIN, n0 = bt0->setPin(c1); NIP) \ - X("SerialBT.unpairDevice", SERIALBT_UNPAIR_DEVICE, \ + XV(BLUETOOTH, "SerialBT.new", SERIALBT_NEW, PUSH new BluetoothSerial()) \ + XV(BLUETOOTH, "SerialBT.delete", SERIALBT_DELETE, delete bt0; DROP) \ + XV(BLUETOOTH, "SerialBT.begin", SERIALBT_BEGIN, n0 = bt0->begin(c2, n1); NIPn(2)) \ + XV(BLUETOOTH, "SerialBT.end", SERIALBT_END, bt0->end(); DROP) \ + XV(BLUETOOTH, "SerialBT.available", SERIALBT_AVAILABLE, n0 = bt0->available()) \ + XV(BLUETOOTH, "SerialBT.readBytes", SERIALBT_READ_BYTES, n0 = bt0->readBytes(b2, n1); NIPn(2)) \ + XV(BLUETOOTH, "SerialBT.write", SERIALBT_WRITE, n0 = bt0->write(b2, n1); NIPn(2)) \ + XV(BLUETOOTH, "SerialBT.flush", SERIALBT_FLUSH, bt0->flush(); DROP) \ + XV(BLUETOOTH, "SerialBT.hasClient", SERIALBT_HAS_CLIENT, n0 = bt0->hasClient()) \ + XV(BLUETOOTH, "SerialBT.enableSSP", SERIALBT_ENABLE_SSP, bt0->enableSSP(); DROP) \ + XV(BLUETOOTH, "SerialBT.setPin", SERIALBT_SET_PIN, n0 = bt0->setPin(c1); NIP) \ + XV(BLUETOOTH, "SerialBT.unpairDevice", SERIALBT_UNPAIR_DEVICE, \ n0 = bt0->unpairDevice(b1); NIP) \ - X("SerialBT.connect", SERIALBT_CONNECT, n0 = bt0->connect(c1); NIP) \ - X("SerialBT.connectAddr", SERIALBT_CONNECT_ADDR, n0 = bt0->connect(b1); NIP) \ - X("SerialBT.disconnect", SERIALBT_DISCONNECT, n0 = bt0->disconnect()) \ - X("SerialBT.connected", SERIALBT_CONNECTED, n0 = bt0->connected(n1); NIP) \ - X("SerialBT.isReady", SERIALBT_IS_READY, n0 = bt0->isReady(n2, n1); NIPn(2)) \ + XV(BLUETOOTH, "SerialBT.connect", SERIALBT_CONNECT, n0 = bt0->connect(c1); NIP) \ + XV(BLUETOOTH, "SerialBT.connectAddr", SERIALBT_CONNECT_ADDR, n0 = bt0->connect(b1); NIP) \ + XV(BLUETOOTH, "SerialBT.disconnect", SERIALBT_DISCONNECT, n0 = bt0->disconnect()) \ + XV(BLUETOOTH, "SerialBT.connected", SERIALBT_CONNECTED, n0 = bt0->connected(n1); NIP) \ + XV(BLUETOOTH, "SerialBT.isReady", SERIALBT_IS_READY, n0 = bt0->isReady(n2, n1); NIPn(2)) \ /* Bluetooth */ \ - Y(esp_bt_dev_get_address, PUSH esp_bt_dev_get_address()) + YV(BLUETOOTH, esp_bt_dev_get_address, PUSH esp_bt_dev_get_address()) #endif #ifndef ENABLE_WIFI_SUPPORT @@ -485,16 +485,16 @@ static cell_t FromIP(IPAddress ip) { # define OPTIONAL_WIFI_SUPPORT \ /* WiFi */ \ - X("WiFi.config", WIFI_CONFIG, \ + XV(WIFI, "WiFi.config", WIFI_CONFIG, \ WiFi.config(ToIP(n3), ToIP(n2), ToIP(n1), ToIP(n0)); DROPn(4)) \ - X("WiFi.begin", WIFI_BEGIN, WiFi.begin(c1, c0); DROPn(2)) \ - X("WiFi.disconnect", WIFI_DISCONNECT, WiFi.disconnect()) \ - X("WiFi.status", WIFI_STATUS, PUSH WiFi.status()) \ - X("WiFi.macAddress", WIFI_MAC_ADDRESS, WiFi.macAddress(b0); DROP) \ - X("WiFi.localIP", WIFI_LOCAL_IPS, PUSH FromIP(WiFi.localIP())) \ - X("WiFi.mode", WIFI_MODE, WiFi.mode((wifi_mode_t) n0); DROP) \ - X("WiFi.setTxPower", WIFI_SET_TX_POWER, WiFi.setTxPower((wifi_power_t) n0); DROP) \ - X("WiFi.getTxPower", WIFI_GET_TX_POWER, PUSH WiFi.getTxPower()) + XV(WIFI, "WiFi.begin", WIFI_BEGIN, WiFi.begin(c1, c0); DROPn(2)) \ + XV(WIFI, "WiFi.disconnect", WIFI_DISCONNECT, WiFi.disconnect()) \ + XV(WIFI, "WiFi.status", WIFI_STATUS, PUSH WiFi.status()) \ + XV(WIFI, "WiFi.macAddress", WIFI_MAC_ADDRESS, WiFi.macAddress(b0); DROP) \ + XV(WIFI, "WiFi.localIP", WIFI_LOCAL_IPS, PUSH FromIP(WiFi.localIP())) \ + XV(WIFI, "WiFi.mode", WIFI_MODE, WiFi.mode((wifi_mode_t) n0); DROP) \ + XV(WIFI, "WiFi.setTxPower", WIFI_SET_TX_POWER, WiFi.setTxPower((wifi_power_t) n0); DROP) \ + XV(WIFI, "WiFi.getTxPower", WIFI_GET_TX_POWER, PUSH WiFi.getTxPower()) #endif #ifndef ENABLE_MDNS_SUPPORT @@ -517,27 +517,27 @@ static cell_t FromIP(IPAddress ip) { static Adafruit_SSD1306 *oled_display = 0; # endif # define OPTIONAL_OLED_SUPPORT \ - Y(OledAddr, PUSH &oled_display) \ - Y(OledNew, oled_display = new Adafruit_SSD1306(n2, n1, &Wire, n0); DROPn(3)) \ - Y(OledDelete, delete oled_display) \ - Y(OledBegin, n0 = oled_display->begin(n1, n0); NIP) \ - Y(OledHOME, oled_display->setCursor(0,0); DROP) \ - Y(OledCLS, oled_display->clearDisplay()) \ - Y(OledTextc, oled_display->setTextColor(n0); DROP) \ - Y(OledPrintln, oled_display->println(c0); DROP) \ - Y(OledNumln, oled_display->println(n0); DROP) \ - Y(OledNum, oled_display->print(n0); DROP) \ - Y(OledDisplay, oled_display->display()) \ - Y(OledPrint, oled_display->write(c0); DROP) \ - Y(OledInvert, oled_display->invertDisplay(n0); DROP) \ - Y(OledTextsize, oled_display->setTextSize(n0); DROP) \ - Y(OledSetCursor, oled_display->setCursor(n1,n0); DROPn(2)) \ - Y(OledPixel, oled_display->drawPixel(n2, n1, n0); DROPn(2)) \ - Y(OledDrawL, oled_display->drawLine(n4, n3, n2, n1, n0); DROPn(4)) \ - Y(OledCirc, oled_display->drawCircle(n3,n2, n1, n0); DROPn(3)) \ - Y(OledCircF, oled_display->fillCircle(n3, n2, n1, n0); DROPn(3)) \ - Y(OledRect, oled_display->drawRect(n4, n3, n2, n1, n0); DROPn(4)) \ - Y(OledRectF, oled_display->fillRect(n4, n3, n2, n1, n0); DROPn(3)) \ - Y(OledRectR, oled_display->drawRoundRect(n5, n4, n3, n2, n1, n0); DROPn(5)) \ - Y(OledRectRF, oled_display->fillRoundRect(n5, n4, n3, n2, n1, n0 ); DROPn(5)) + YV(OLED, OledAddr, PUSH &oled_display) \ + YV(OLED, OledNew, oled_display = new Adafruit_SSD1306(n2, n1, &Wire, n0); DROPn(3)) \ + YV(OLED, OledDelete, delete oled_display) \ + YV(OLED, OledBegin, n0 = oled_display->begin(n1, n0); NIP) \ + YV(OLED, OledHOME, oled_display->setCursor(0,0); DROP) \ + YV(OLED, OledCLS, oled_display->clearDisplay()) \ + YV(OLED, OledTextc, oled_display->setTextColor(n0); DROP) \ + YV(OLED, OledPrintln, oled_display->println(c0); DROP) \ + YV(OLED, OledNumln, oled_display->println(n0); DROP) \ + YV(OLED, OledNum, oled_display->print(n0); DROP) \ + YV(OLED, OledDisplay, oled_display->display()) \ + YV(OLED, OledPrint, oled_display->write(c0); DROP) \ + YV(OLED, OledInvert, oled_display->invertDisplay(n0); DROP) \ + YV(OLED, OledTextsize, oled_display->setTextSize(n0); DROP) \ + YV(OLED, OledSetCursor, oled_display->setCursor(n1,n0); DROPn(2)) \ + YV(OLED, OledPixel, oled_display->drawPixel(n2, n1, n0); DROPn(2)) \ + YV(OLED, OledDrawL, oled_display->drawLine(n4, n3, n2, n1, n0); DROPn(4)) \ + YV(OLED, OledCirc, oled_display->drawCircle(n3,n2, n1, n0); DROPn(3)) \ + YV(OLED, OledCircF, oled_display->fillCircle(n3, n2, n1, n0); DROPn(3)) \ + YV(OLED, OledRect, oled_display->drawRect(n4, n3, n2, n1, n0); DROPn(4)) \ + YV(OLED, OledRectF, oled_display->fillRect(n4, n3, n2, n1, n0); DROPn(3)) \ + YV(OLED, OledRectR, oled_display->drawRoundRect(n5, n4, n3, n2, n1, n0); DROPn(5)) \ + YV(OLED, OledRectRF, oled_display->fillRoundRect(n5, n4, n3, n2, n1, n0 ); DROPn(5)) #endif diff --git a/ueforth/esp32/options.h b/ueforth/esp32/options.h index dd657a9..baed852 100644 --- a/ueforth/esp32/options.h +++ b/ueforth/esp32/options.h @@ -64,3 +64,9 @@ # define ENABLE_SERIAL_BLUETOOTH_SUPPORT # endif #endif + +enum { + RTOS = 2, REGISTERS, SPIFFS, SERIAL, TASKS, SD, SD_MMC, LEDC, + WIRE, WIFI, EDITOR, BLUETOOTH, SOCKETS, STREAMS, OLED, + RMT, INTERRUPTS, SPI_FLASH, CAMERA, +}; diff --git a/ueforth/esp32/print-builtins.cpp b/ueforth/esp32/print-builtins.cpp index c91d457..b14cde2 100644 --- a/ueforth/esp32/print-builtins.cpp +++ b/ueforth/esp32/print-builtins.cpp @@ -23,14 +23,16 @@ #define USER_WORDS #include "builtins.h" -#define Y(name, code) X(#name, name, code) +#define YV(flags, op, code) XV(flags, #op, op, code) +#define X(name, op, code) XV(FORTH, name, op, code) +#define Y(op, code) XV(FORTH, #op, op, code) int main() { printf("#define PLATFORM_SIMULATED_OPCODE_LIST \\\n"); -#define X(str, name, code) \ - printf(" X(\"%s\", %s, DUP; sp = simulated(sp, STR_%s); DROP) \\\n", str, #name, #name); +#define XV(flags, str, name, code) \ + printf(" XV(%s, \"%s\", %s, DUP; sp = simulated(sp, STR_%s); DROP) \\\n", #flags, str, #name, #name); PLATFORM_OPCODE_LIST -#undef X +#undef XV printf("\n"); return 0; } diff --git a/ueforth/esp32/sim_main.cpp b/ueforth/esp32/sim_main.cpp index a29f22b..79ae5ef 100644 --- a/ueforth/esp32/sim_main.cpp +++ b/ueforth/esp32/sim_main.cpp @@ -29,9 +29,9 @@ static cell_t *simulated(cell_t *sp, const char *op); #include "gen/esp32_sim_opcodes.h" -#define X(str, name, code) static const char *STR_ ## name = str; +#define XV(flags, str, name, code) static const char *STR_ ## name = str; PLATFORM_SIMULATED_OPCODE_LIST -#undef X +#undef XV #include "common/core.h" #include "common/interp.h" diff --git a/ueforth/web/dump_web_opcodes.c b/ueforth/web/dump_web_opcodes.c index 58a85ce..cc77b5a 100644 --- a/ueforth/web/dump_web_opcodes.c +++ b/ueforth/web/dump_web_opcodes.c @@ -24,24 +24,24 @@ enum { OP_DOCOLON = 0, OP_DOCREATE = 1, OP_DODOES = 2, -#define X(name, op, code) OP_ ## op, +#define XV(flags, name, op, code) OP_ ## op, PLATFORM_OPCODE_LIST OPCODE_LIST -#undef X +#undef XV }; int main(int argc, char *argv[]) { if (argc == 2 && strcmp(argv[1], "cases") == 0) { -#define X(name, op, code) \ +#define XV(flags, name, op, code) \ printf(" case %d: // %s\n %s; break;\n", OP_ ## op, name, #code); PLATFORM_OPCODE_LIST OPCODE_LIST -#undef X +#undef XV } else if (argc == 2 && strcmp(argv[1], "dict") == 0) { -#define X(name, op, code) printf(" create(" #name ", %d);\n", OP_ ## op); +#define XV(flags, name, op, code) printf(" create(" #name ", %d);\n", OP_ ## op); PLATFORM_OPCODE_LIST OPCODE_LIST -#undef X +#undef XV } else { fprintf(stderr, "USAGE: %s cases/dict\n", argv[1]); return 1; diff --git a/ueforth/windows/interp.h b/ueforth/windows/interp.h index fead6c6..bab906c 100644 --- a/ueforth/windows/interp.h +++ b/ueforth/windows/interp.h @@ -22,21 +22,33 @@ enum { OP_DOCOLON = 0, OP_DOCREATE, OP_DODOES, -#define X(name, op, code) OP_ ## op, +#define XV(flags, name, op, code) OP_ ## op, PLATFORM_OPCODE_LIST EXTRA_OPCODE_LIST OPCODE_LIST -#undef X +#undef XV }; static cell_t *forth_run(cell_t *init_rp) { + static const struct { + const char *name; + cell_t flags; + const void *code; + } foo[] = { +#define XV(flags, name, op, code) name, 0, (void *) OP_ ## op, + PLATFORM_OPCODE_LIST + EXTRA_OPCODE_LIST + OPCODE_LIST +#undef XV + }; + if (!init_rp) { -#define X(name, op, code) \ +#define XV(flags, name, op, code) \ create(name, sizeof(name) - 1, name[0] == ';', (void *) OP_ ## op); PLATFORM_OPCODE_LIST EXTRA_OPCODE_LIST OPCODE_LIST -#undef X +#undef XV return 0; } register cell_t *ip, *rp, *sp, tos, w; @@ -47,11 +59,11 @@ next: w = *ip++; work: switch (*(cell_t *) w & 0xff) { -#define X(name, op, code) case OP_ ## op: { code; } NEXT; +#define XV(flags, name, op, code) case OP_ ## op: { code; } NEXT; PLATFORM_OPCODE_LIST EXTRA_OPCODE_LIST OPCODE_LIST -#undef X +#undef XV case OP_DOCOLON: ++rp; *rp = (cell_t) ip; ip = (cell_t *) (w + sizeof(cell_t)); NEXT; case OP_DOCREATE: DUP; tos = w + sizeof(cell_t) * 2; NEXT; case OP_DODOES: DUP; tos = w + sizeof(cell_t) * 2;