Added M80 example

This commit is contained in:
Willem Cazander 2021-07-06 03:52:02 +02:00
parent 656c3436da
commit 6cec28f1bc
13 changed files with 110 additions and 77 deletions

View file

@ -5,4 +5,5 @@
#PATH_SDCC ?= /usr/bin #PATH_SDCC ?= /usr/bin
#PATH_HEX2BIN ?= /usr/bin #PATH_HEX2BIN ?= /usr/bin
#PATH_UNIX2DOS ?= /usr/bin
#PATH_OPENMSX ?= /opt/openMSX/bin/ #PATH_OPENMSX ?= /opt/openMSX/bin/

View file

@ -20,6 +20,7 @@ for your specific needs or contribute a fix or feature.
* sdcc * sdcc
* hex2bin * hex2bin
* wget * wget
* unix2dos
## Usage ## Usage
@ -27,6 +28,7 @@ Include the msxbuild.mk file from your Makefile.
And override the required paths; And override the required paths;
* PATH_SDCC ?= /usr/bin * PATH_SDCC ?= /usr/bin
* PATH_HEX2BIN ?= /usr/bin * PATH_HEX2BIN ?= /usr/bin
* PATH_UNIX2DOS ?= /usr/bin
* PATH_OPENMSX ?= /opt/openMSX/bin/ * PATH_OPENMSX ?= /opt/openMSX/bin/
* PATH_MSXBUILD ?= /opt/msxbuild * PATH_MSXBUILD ?= /opt/msxbuild

View file

@ -1,33 +0,0 @@
define _mb_assert_success
@echo success: mb_assert_$(1)\; \'$(2)\'
endef
define _mb_assert_failure
@echo failure: mb_assert_$(1)\; \'$(2)\'
@exit 1
endef
define _mb_assert_if
$(if $(1),$(call _mb_assert_success,$(2),$(3)),$(call _mb_assert_failure,$(2),$(3)))
endef
define _mb_assert_if_not
$(if $(1),$(call _mb_assert_failure,$(2),$(3)),$(call _mb_assert_success,$(2),$(3)))
endef
# FIXME: Not stable
#define mb_assert_file_contains
# $(call _mb_assert_if,$(findstring $(2),$(file < $(1))),file_contains,$(2))
#endef
define mb_assert_file_equals
$(call _mb_assert_if_not,$(subst $(2),,$(file < $(1))),file_equals,$(2))
endef
# Assert that the variable(s) are set and doesn't have non-empty values.
# Params;
# 1. Variable name(s) to validate.
# 2. (optional) Error message to user.
define mb_assert_defined
$(strip $(foreach 1,$1,$(call _mb_assert_defined_error,$1,$(strip $(value 2)))))
endef
define _mb_assert_defined_error
$(if $(value $1),,$(error Undefined $1$(if $2, ($2))))
endef

View file

@ -21,6 +21,9 @@ endif
# Remove space after separator # Remove space after separator
MB_PSEP = $(strip $(MB_SEP)) MB_PSEP = $(strip $(MB_SEP))
# Needed for comma in call arguments (like for l80.com)
MB_COMMA:=,
define mb_clean define mb_clean
@echo === Cleaning build folder. @echo === Cleaning build folder.
test $(1) && $(MB_RMDIR) $(1) test $(1) && $(MB_RMDIR) $(1)

View file

@ -7,11 +7,16 @@ MB_BUILD_H2B_CMD ?= $(PATH_HEX2BIN)/hex2bin
MB_BUILD_SDCC_CMD ?= $(PATH_SDCC)/sdcc MB_BUILD_SDCC_CMD ?= $(PATH_SDCC)/sdcc
MB_BUILD_SDASM_CMD ?= $(PATH_SDCC)/sdasz80 MB_BUILD_SDASM_CMD ?= $(PATH_SDCC)/sdasz80
MB_BUILD_SDAR_CMD ?= $(PATH_SDCC)/sdar MB_BUILD_SDAR_CMD ?= $(PATH_SDCC)/sdar
MB_BUILD_UNIX2DOS_CMD ?= $(PATH_UNIX2DOS)/unix2dos
# TODO: Add C + mixed support; # TODO: Add C + mixed support;
#$(MB_SDASM) -I$(MB_LIBASM_SRC)/include #$(MB_SDASM) -I$(MB_LIBASM_SRC)/include
#-l$(LIBASM_LINK) #-l$(LIBASM_LINK)
define mb_unix2dos
$(MB_BUILD_UNIX2DOS_CMD) -n $(1) $(2)
endef
define mb_compile_asm define mb_compile_asm
@echo === Compile module asm. @echo === Compile module asm.
$(MB_BUILD_SDASM_CMD) $(MB_BUILD_SDASM_FLAGS) $(1) $(2) $(MB_BUILD_SDASM_CMD) $(MB_BUILD_SDASM_FLAGS) $(1) $(2)

View file

@ -26,3 +26,10 @@ define mb_msxhub_get_dos2_com
$(call mb_msxhub_file,$(1)/COMMAND2.COM,$(MB_MSXHUB_API)/MSXDOS2/2.20-1/get/MSXDOS2/COMMAND2.COM) $(call mb_msxhub_file,$(1)/COMMAND2.COM,$(MB_MSXHUB_API)/MSXDOS2/2.20-1/get/MSXDOS2/COMMAND2.COM)
endef endef
define mb_msxhub_get_macro80
$(call mb_msxhub_file,$(1)/CREF80.COM,$(MB_MSXHUB_API)/MACRO80/2.0-1/get/MACRO80/CREF80.COM)
$(call mb_msxhub_file,$(1)/L80.COM,$(MB_MSXHUB_API)/MACRO80/2.0-1/get/MACRO80/L80.COM)
$(call mb_msxhub_file,$(1)/LIB80.COM,$(MB_MSXHUB_API)/MACRO80/2.0-1/get/MACRO80/LIB80.COM)
$(call mb_msxhub_file,$(1)/M80.COM,$(MB_MSXHUB_API)/MACRO80/2.0-1/get/MACRO80/M80.COM)
endef

View file

@ -3,7 +3,8 @@ MB_OPENMSX_BOOT_TIMEOUT ?= 25
MB_OPENMSX_MACHINE ?= Philips_NMS_8250 MB_OPENMSX_MACHINE ?= Philips_NMS_8250
MB_OPENMSX_JOYPORTA ?= MB_OPENMSX_JOYPORTA ?=
MB_OPENMSX_JOYPORTB ?= MB_OPENMSX_JOYPORTB ?=
MB_OPENMSX_SETTING ?= $(PATH_MSXBUILD)/lib/openmsx/boot_settings.xml # Workaround for include msxbuild.mk file and 'older' openmsx segfaults on relative settings path.
MB_OPENMSX_SETTING := $(if $(realpath $(PATH_MSXBUILD)),$(realpath $(PATH_MSXBUILD)),$(PATH_MSXBUILD))/lib/openmsx/boot_settings.xml
MB_OPENMSX_EXTS ?= MB_OPENMSX_EXTS ?=
MB_OPENMSX_EXTRA_MEM ?= -ext ram4mb MB_OPENMSX_EXTRA_MEM ?= -ext ram4mb
MB_OPENMSX_ARGS = \ MB_OPENMSX_ARGS = \

View file

@ -5,6 +5,7 @@
# Setup required tools paths # Setup required tools paths
PATH_HEX2BIN ?= /usr/bin PATH_HEX2BIN ?= /usr/bin
PATH_SDCC ?= /usr/bin PATH_SDCC ?= /usr/bin
PATH_UNIX2DOS ?= /usr/bin
PATH_OPENMSX ?= /usr/bin PATH_OPENMSX ?= /usr/bin
PATH_MSXBUILD ?= $(dir $(lastword $(MAKEFILE_LIST)))../.. PATH_MSXBUILD ?= $(dir $(lastword $(MAKEFILE_LIST)))../..
@ -13,5 +14,4 @@ include $(PATH_MSXBUILD)/lib/make/mb_base.mk
include $(PATH_MSXBUILD)/lib/make/mb_autoexec.mk include $(PATH_MSXBUILD)/lib/make/mb_autoexec.mk
include $(PATH_MSXBUILD)/lib/make/mb_msxhub.mk include $(PATH_MSXBUILD)/lib/make/mb_msxhub.mk
include $(PATH_MSXBUILD)/lib/make/mb_openmsx.mk include $(PATH_MSXBUILD)/lib/make/mb_openmsx.mk
include $(PATH_MSXBUILD)/lib/make/mb_assert.mk
include $(PATH_MSXBUILD)/lib/make/mb_build.mk include $(PATH_MSXBUILD)/lib/make/mb_build.mk

View file

@ -0,0 +1,33 @@
TEST_AHELLO_M80 := $(PATH_BIN)/test/ahello-m80
BUILD_HELP += \\n\\t* $(TEST_AHELLO_M80)/ahello.com\\n\\t* test-ahello-m80-run\\n\\t* test-ahello-m80-assert
$(TEST_AHELLO_M80):
$(call mb_mkdir,$(TEST_AHELLO_M80))
$(call mb_msxhub_get_macro80,$(TEST_AHELLO_M80))
$(TEST_AHELLO_M80)/%.mac: test/ahello-m80/%.mac | $(TEST_AHELLO_M80)
$(call mb_unix2dos,$<,$@)
$(TEST_AHELLO_M80)/ahello.rel: $(TEST_AHELLO_M80)/ahello.mac
$(call mb_autoexec_cmd,$(TEST_AHELLO_M80),m80 =ahello/Z)
$(call mb_openmsx_dos2,$(TEST_AHELLO_M80))
$(TEST_AHELLO_M80)/ahello.hex: $(TEST_AHELLO_M80)/ahello.rel
$(call mb_autoexec_cmd,$(TEST_AHELLO_M80),l80 ahello$(MB_COMMA)ahello/N/X/Y/E)
$(call mb_openmsx_dos2,$(TEST_AHELLO_M80))
$(TEST_AHELLO_M80)/ahello.com: $(TEST_AHELLO_M80)/ahello.hex
$(call mb_hex2com,$(TEST_AHELLO_M80)/ahello.hex,$(TEST_AHELLO_M80)/ahello.com)
.PHONY: test-ahello-m80-run
test-ahello-m80-run: $(TEST_AHELLO_M80)/ahello.com
$(call mb_autoexec_open_gui,$(TEST_AHELLO_M80))
$(call mb_openmsx_dos2,$(TEST_AHELLO_M80))
.PHONY: test-ahello-m80-assert
test-ahello-m80-assert: $(TEST_AHELLO_M80)/ahello.com
$(call mb_delete,$(TEST_AHELLO_M80)/test.out)
$(call mb_autoexec_cmd_test,$(TEST_AHELLO_M80),ahello > test.out)
$(call mb_openmsx_dos2,$(TEST_AHELLO_M80))
grep "M80: Hello world..." $(TEST_AHELLO_M80)/test.out

View file

@ -0,0 +1,20 @@
title M80 CP/M Hello world
.Z80
WRITESTR EQU 9h
BDOS EQU 5h
ASEG
ORG 0100H
MAIN:
LD C,WRITESTR
LD DE,TXT_HELLO
CALL BDOS
RET
TXT_HELLO:
DB "M80: Hello world...$"
END
DSEG

View file

@ -0,0 +1,27 @@
TEST_AHELLO_SDCC := $(PATH_BIN)/test/ahello-sdcc
BUILD_HELP += \\n\\t* $(TEST_AHELLO_SDCC)/ahello.com\\n\\t* test-ahello-sdcc-run\\n\\t* test-ahello-sdcc-assert
$(TEST_AHELLO_SDCC):
$(call mb_mkdir,$(TEST_AHELLO_SDCC))
$(TEST_AHELLO_SDCC)/%.rel: test/ahello-sdcc/%.asm | $(TEST_AHELLO_SDCC)
$(call mb_compile_asm,$@,$<)
$(TEST_AHELLO_SDCC)/ahello.hex: $(TEST_AHELLO_SDCC)/ahello.rel
$(call mb_link_asm_dos,$(TEST_AHELLO_SDCC)/ahello.hex,$(TEST_AHELLO_SDCC)/ahello.rel)
$(TEST_AHELLO_SDCC)/ahello.com: $(TEST_AHELLO_SDCC)/ahello.hex
$(call mb_hex2com,$(TEST_AHELLO_SDCC)/ahello.hex,$(TEST_AHELLO_SDCC)/ahello.com)
.PHONY: test-ahello-sdcc-run
test-ahello-sdcc-run: $(TEST_AHELLO_SDCC)/ahello.com
$(call mb_autoexec_open_gui,$(TEST_AHELLO_SDCC))
$(call mb_openmsx_dos2,$(TEST_AHELLO_SDCC))
.PHONY: test-ahello-sdcc-assert
test-ahello-sdcc-assert: $(TEST_AHELLO_SDCC)/ahello.com
$(call mb_delete,$(TEST_AHELLO_SDCC)/test.out)
$(call mb_autoexec_cmd_test,$(TEST_AHELLO_SDCC),ahello > test.out)
$(call mb_openmsx_dos2,$(TEST_AHELLO_SDCC))
grep "SDCC: Hello world..." $(TEST_AHELLO_SDCC)/test.out

View file

@ -31,7 +31,7 @@ PUT_TXT:
JR PUT_TXT JR PUT_TXT
TXT_HELLO: TXT_HELLO:
.str "Hello world..." .str "SDCC: Hello world..."
.db 0x1D .db 0x1D
TXT_HELLO_SRC: TXT_HELLO_SRC:

View file

@ -1,33 +0,0 @@
ASM_HELLO_NAME := ahello
ASM_HELLO_RUN := run-$(ASM_HELLO_NAME)
ASM_HELLO_TEST := test-$(ASM_HELLO_NAME)
ASM_HELLO_SRC := test/$(ASM_HELLO_NAME)
ASM_HELLO_BIN := $(PATH_BIN)/test/$(ASM_HELLO_NAME)
ASM_HELLO_HEX := $(ASM_HELLO_BIN)/$(ASM_HELLO_NAME).hex
ASM_HELLO_COM := $(ASM_HELLO_BIN)/$(ASM_HELLO_NAME).com
ASM_HELLO_RELS := $(ASM_HELLO_BIN)/$(ASM_HELLO_NAME).rel
ASM_HELLO_CODE := $(ASM_HELLO_SRC)/$(ASM_HELLO_NAME).asm
BUILD_HELP += \\n\\t* $(ASM_HELLO_COM)\\n\\t* $(ASM_HELLO_RUN)\\n\\t* $(ASM_HELLO_TEST) \(Change txt in hello.asm and run again\)
$(ASM_HELLO_BIN):
$(call mb_mkdir,$(ASM_HELLO_BIN))
$(ASM_HELLO_BIN)/%.rel: $(ASM_HELLO_SRC)/%.asm | $(ASM_HELLO_BIN)
$(call mb_compile_asm,$@,$<)
$(ASM_HELLO_HEX): $(ASM_HELLO_RELS)
$(call mb_link_asm_dos,$(ASM_HELLO_HEX),$(ASM_HELLO_RELS))
$(ASM_HELLO_COM): $(ASM_HELLO_HEX)
$(call mb_hex2com,$(ASM_HELLO_HEX),$(ASM_HELLO_COM))
$(ASM_HELLO_RUN): $(ASM_HELLO_COM)
$(call mb_autoexec_open_gui,$(ASM_HELLO_BIN))
$(call mb_openmsx_dos2,$(ASM_HELLO_BIN))
$(ASM_HELLO_TEST): $(ASM_HELLO_COM)
$(call mb_delete,$(ASM_HELLO_BIN)/test.out)
$(call mb_autoexec_cmd_test,$(ASM_HELLO_BIN),$(ASM_HELLO_NAME) > test.out)
$(call mb_openmsx_dos2,$(ASM_HELLO_BIN))
$(call mb_assert_file_equals,$(ASM_HELLO_BIN)/test.out,Hello world...from asm.)