diff --git a/examples/Makefile b/examples/Makefile index 6e2fc103..ac50bb95 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -38,6 +38,7 @@ EXS = \ mn1610 \ mos6502 \ ns32000 \ + pdp11 \ pdp8 \ scn2650 \ tlcs90 \ diff --git a/examples/pdp11/Makefile b/examples/pdp11/Makefile new file mode 100644 index 00000000..eb0c066f --- /dev/null +++ b/examples/pdp11/Makefile @@ -0,0 +1,109 @@ +# Copyright 2021 Tadashi G. Takaoka +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +help: + @echo '"make clean" remove unnecessary files' + @echo '"make pio-ci" run PlatformIO CI for a board' + @echo " (default BOARD=$(BOARD))" + @echo '"make pio-ci-all" run PlatformIO CI for all boards' + @echo " ($(BOARDS))" + @echo '"make pio-run" build sketch for an environment' + @echo " (default ENV=$(ENV))" + @echo '"make pio-run-all" build sketch for all environments' + @echo " ($(ENVS))" + +ifdef INSIDE_EMACS +ifeq ($(filter $(PIO_FLAGS),"--no-ansi"),) +PIO_FLAGS += --no-ansi +endif +ifeq ($(filter $(ARDUINO_FLAGS),"--no-color"),) +ARDUINO_FLAGS += --no-color +endif +endif + +PIO_CI_FLAGS = +ARDUINO_CI_FLAGS = --warnings all --library $(CURDIR)/../../ + +ENVS = $(shell grep -Po '^\[env:\K[^]]+' platformio.ini) +ENV ?= $(firstword $(ENVS)) + +BOARDS = $(shell grep -Po '^board *= *\K[\w]+' platformio.ini) +BOARD ?= $(firstword $(BOARDS)) + +EXAMPLE = $(shell basename $(CURDIR)) + +define pio-libdep-path # env libdep +-l .pio/libdeps/$(1)/$(2) +endef + +define pio-ci # board + ENV=$(shell awk 'BEGIN{RS="\n\n"} /$(1)/' platformio.ini | grep -Po '(?<=env:)[^]]+') + pio $(PIO_FLAGS) pkg install -l libcli + pio $(PIO_FLAGS) ci -l $(CURDIR)/../.. $(call pio-libdep-path,$(ENV),libcli) -b $(1) $(EXAMPLE).ino + +endef + +pio-ci: + $(call pio-ci,$(BOARD)) + +pio-ci-all: + $(foreach board,$(BOARDS),$(call pio-ci,$(board))) + +boards: platformio.ini + @echo $(BOARDS) + +define pio-run # env + pio $(PIO_FLAGS) run $(PIO_RUN_FLAGS) -e $(1) + +endef + +pio-run: + $(call pio-run,$(ENV)) + +pio-run-all: + $(foreach env,$(ENVS),$(call pio-run,$(env))) + +envs: platformio.ini + @echo $(ENVS) + +define arduino-ci # fqbn + arduino-cli $(ARDUINO_FLAGS) compile -b $(1) $(ARDUINO_CI_FLAGS) + +endef + +FQBNS = \ + MightyCore:avr:1284 \ + DxCore:megaavr:avrda \ + teensy:avr:teensy41 +FQBN ?= $(firstword $(FQBNS)) + +fqbns: + @echo $(FQBNS) + +arduino-ci: + $(call arduino-ci,$(FQBN)) + +arduino-ci-all: + $(foreach fqbn,$(FQBNS),$(call arduino-ci,$(fqbn))) + +clean: + rm -rf $$(find . -type d -a -name .pio) + +.PHONY: help clean pio-run pio-run-all pio-ci pio-ci-all pio-boards pio-envs \ + arduino-ci arduino-ci-all + +# Local Variables: +# mode: makefile-gmake +# End: +# vim: set ft=make: diff --git a/examples/pdp11/pdp11.ino b/examples/pdp11/pdp11.ino new file mode 100644 index 00000000..9181533c --- /dev/null +++ b/examples/pdp11/pdp11.ino @@ -0,0 +1,40 @@ +/* + * Copyright 2024 Tadashi G. Takaoka + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +libasm::pdp11::AsmPdp11 asmpdp11; +libasm::pdp11::DisPdp11 dispdp11; + +libasm::arduino::Example example(asmpdp11, dispdp11); + +void setup() { + Serial.begin(9600); + example.begin(Serial); +} + +void loop() { + example.loop(); +} + +// Local Variables: +// mode: c++ +// c-basic-offset: 2 +// tab-width: 2 +// End: +// vim: set ft=cpp et ts=2 sw=2: diff --git a/examples/pdp11/platformio.ini b/examples/pdp11/platformio.ini new file mode 100644 index 00000000..9a9f914f --- /dev/null +++ b/examples/pdp11/platformio.ini @@ -0,0 +1,33 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +src_dir = . +default_envs = atmega1284p, avr128da, teensy41 + +[env] +lib_deps = + tgtakaoka/libcli@1.3.0 + tgtakaoka/libasm@1.6.48 + +[env:atmega1284p] +platform = atmelavr +board = ATmega1284P +framework = arduino + +[env:avr128da] +platform = atmelmegaavr +board = AVR128DA48 +framework = arduino + +[env:teensy41] +platform = teensy +board = teensy41 +framework = arduino diff --git a/src/arduino_example.h b/src/arduino_example.h index e5f179ed..0a80a552 100644 --- a/src/arduino_example.h +++ b/src/arduino_example.h @@ -143,7 +143,7 @@ struct Example { if (!isAsm() && strncasecmp_P(line, PSTR("ORG"), 3) == 0) { const auto org = skipSpaces(line + 3); if (*org) { - uint32_t addr; + uint32_t addr = 0; const auto p = StrMemory::readNumber(org, &addr); if (p == org) { _cli.println(F("illegal ORG address"));