From 12ded3be65c7c6e948734a01799860aec2d5760d Mon Sep 17 00:00:00 2001 From: Shawn Sijnstra <78007189+sijnstra@users.noreply.github.com> Date: Sun, 11 Jun 2023 21:59:49 +1000 Subject: [PATCH] Initial upload of hexdump tool --- hexdump/README.md | 8 + hexdump/Release/hexdump.bin | Bin 0 -> 849 bytes hexdump/Release/hexdump.hex | 19 + hexdump/Release/hexdump.lod | Bin 0 -> 2515 bytes hexdump/Release/hexdump.map | 199 ++++++++ hexdump/Release/hexdump_Release.linkcmd | 58 +++ hexdump/Release/hexdump_Release.mak | 129 +++++ hexdump/Release/init.lst | 308 +++++++++++ hexdump/Release/init.obj | Bin 0 -> 1243 bytes hexdump/Release/main.lst | 647 ++++++++++++++++++++++++ hexdump/Release/main.obj | Bin 0 -> 2631 bytes hexdump/Release/output.lst | 156 ++++++ hexdump/Release/output.obj | Bin 0 -> 601 bytes hexdump/eZ80F92_AGON_Flash.ztgt | 62 +++ hexdump/equs.inc | 93 ++++ hexdump/hexdump.wsp | 44 ++ hexdump/hexdump.zdsproj | 217 ++++++++ hexdump/init.asm | 198 ++++++++ hexdump/main.asm | 302 +++++++++++ hexdump/mos_api.inc | 226 +++++++++ hexdump/output.asm | 54 ++ 21 files changed, 2720 insertions(+) create mode 100644 hexdump/README.md create mode 100644 hexdump/Release/hexdump.bin create mode 100644 hexdump/Release/hexdump.hex create mode 100644 hexdump/Release/hexdump.lod create mode 100644 hexdump/Release/hexdump.map create mode 100644 hexdump/Release/hexdump_Release.linkcmd create mode 100644 hexdump/Release/hexdump_Release.mak create mode 100644 hexdump/Release/init.lst create mode 100644 hexdump/Release/init.obj create mode 100644 hexdump/Release/main.lst create mode 100644 hexdump/Release/main.obj create mode 100644 hexdump/Release/output.lst create mode 100644 hexdump/Release/output.obj create mode 100644 hexdump/eZ80F92_AGON_Flash.ztgt create mode 100644 hexdump/equs.inc create mode 100644 hexdump/hexdump.wsp create mode 100644 hexdump/hexdump.zdsproj create mode 100644 hexdump/init.asm create mode 100644 hexdump/main.asm create mode 100644 hexdump/mos_api.inc create mode 100644 hexdump/output.asm diff --git a/hexdump/README.md b/hexdump/README.md new file mode 100644 index 0000000..7e5a50b --- /dev/null +++ b/hexdump/README.md @@ -0,0 +1,8 @@ +# strings + +Usage: `strings [-nX] ` + +A simple `mos` utility to extract strings from any file. + +The option -nX is used to specify the minimum string length. If not specified, the minimum string length is 4. +Supports values of X from 1 to 99. diff --git a/hexdump/Release/hexdump.bin b/hexdump/Release/hexdump.bin new file mode 100644 index 0000000000000000000000000000000000000000..d9b262efbc2fd7637fe1ec13ade190255c50dd04 GIT binary patch literal 849 zcmb7C&1(};5P!R`R!Q^GT7(tf4~LUiPqugbFR%LlG_6I=itR1&8;3Z{GZ7=FL2&GD}Wuk?Lyu z)Z3?X`3D>yL>)Fd6C-4L^1-e9(YwK$(j5Y=MoS>1HHu1zygGs^?10fYNE*TgPUAS# zwf6)Jvy*5N-b~nr@*%X$)=vaUjA^D7^7h1 z?aEa0pCa@URTV^zCM%i@@h{$8RqDLX5&MpZAH z#YR;VY1s_86{~w|k6VwJBGYx-g`(o$Ll6t?xT1EAcY@l^UHp1vUu6D$ZGta&T%_`b z>zSkddT;l!7Uj|R64m`jNFvw9$|7g62(@1Bib2)XrunaWpjcwRRP7<}G~mW*61nlF zFZ_t#v>OKOSlFN+YkAbpSaj1gF^Tq;udF&a$vK%<;?EXyi6<Tm7cS2q9v literal 0 HcmV?d00001 diff --git a/hexdump/Release/hexdump.hex b/hexdump/Release/hexdump.hex new file mode 100644 index 0000000..d136f5c --- /dev/null +++ b/hexdump/Release/hexdump.hex @@ -0,0 +1,19 @@ +:020000040004F6 +:03000000C35100E9 +:0300080049CFC914 +:0300100049D7C904 +:03003800FBED4D90 +:400040004D4F53000048455844554D502E42494E005BFDE5FD210000FD395BFDE5310080F55BC55BD55BDDE5ED6EDD211501CD01015BDDE5CD91005BDDE10600CD49015B44 +:40008000DDE15BD15BC1F15BFDE1FDF95BFDE149C9014500CDEF005BDD0F005BDD235BDD235BDD23CDE600010100060FC55BE5CDD500795BD1C1B7C85BDD1F005BE55BD15C +:4000C000CDE600AF5B125BDD235BDD235BDD230C79B838D8C90E005B7EB7C8FE0DC8FE20C85B230C18F15B7EFE20C05B2318F75BE55BC55B210200005B395B775BC15BE178 +:40010000C95BDDE55BDD210200005BDD395BDD77005BDDE1C9000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C +:400140000000000000211300C9793DCA7C02FE03D282025BDD27030E013E0A49CFB7200E210400C90E003E0B49CF210000C93251033E0849CFDD7E1932BB035B21F0FFFF7E +:400180005B2252030B5B2156030B5B111000003A51034F3E1A49CF7BB7CA2E02475B2A52030B5B111000005B195B2252030BC5CD2903C13E3AD72156030E0079E6032007B5 +:4001C0003E20E5C5D7C1E17EE5C5CD3E03C1E1230C79FE10CAE801B838E13E20D7D779E60320033E20D718E83E20D73E7CD72156030E007ECD3702E5C5D7C1E1230C79FE0B +:4002000010CA0B02B838EC3E2018ECCD41027C0D0A00C385011156031AD71310FBCD4D02CD37022803D718F5CD41020D0A00CD41020D0A00C36401FE203803FE7FD83E2E73 +:40024000C9E1CD4802E9D7237EB720FAC9CD59023A51034F3E0C49CFC93E013DE60F325A02C03E0849CF5BDD7E1921BB03BEC8775BDD7E05FE03C0E1E1C36401CD8802C34A +:400280006A01CD8802C34501CD41020D0A68657864756D70207574696C69747920666F722041676F6E20627920536861776E2053696A6E737472612031312D4A756E2D324C +:4002C0003032330D0A0D0A55736167653A0D0A20202068657864756D70203C66696C653E0D0A0D0A53746F72652068657864756D702E62696E20696E202F6D6F7320646921 +:40030000726563746F72792E204D696E696D756D204D4F532076657273696F6E20312E30332E0D0A0D0A00C9045BE55B210200005B395B7E5BE1CD3E037CCD3E037D4F1F61 +:110340001F1F1FCD470379E60FC69027CE4027D7C978 +:00000001FF diff --git a/hexdump/Release/hexdump.lod b/hexdump/Release/hexdump.lod new file mode 100644 index 0000000000000000000000000000000000000000..37e05cf9773a5a1a426ffce4ac9d7a49e87308b9 GIT binary patch literal 2515 zcmZuz-)~b@9KYwBc8tQtkSv+La3^77#?`IsMp?9OvIS;RV4D#2E+L&OP_nk9-5d)O z&D2ES^e^!dBgQ}$(JtPC7*b!FNF&QgXlx%0QM2Lse7~o63{9Hv@1N&cl#2>DQ!e@-x5`C7@WXPk!SFkvzgs=nF#Ohuvweqa zg@e{XVO2YrkJJhsR)?r|GJB*}=(IXzHAHNGPpuHLLRb7&>&yMsFv~)bA?6I~Va}ik za}k942T?0AmJC%??BpcVM=Qbj=u(c%YGQqn(

*&zAGUr#Y(c`#y>{r>>+Ii)=&_5rdiJ&oKo(g^`18}?`@xN?-N+;>GY1si?_UL4cF@4QqGWc;Orgnq{)pqWx`7t+%R z$><=+q6SLm)`*+pQClN{y#wN?4MSW41tAxnLOOUF5>Kn#sFy;J{s0`kQInf3npdmq zIB7F?Ff&%tJ1m!)0z7My7Hs8HG^F;@NeWySr`ZSB7Ce2*jUl8dM;@YM;&$*}HRzaL$l$Yr zFg#agkb^f%M(9vBKhzR|#g$Pw@v!4Sm3y2zcnB#SEA{EEw6y=O+bj1Ss%+cD;l}D8 z2ar+Z7T6%UhDS<;-lh0ANVzrXdY5?A+iBFrcW}d-Ar>@%)(;O_KLKZ+5-OP+RPJX~ z&dNok^te%QuhS`+Z?ZiT3!#1?Y8+#^{}s=OU@>uTjsx4h9>7S*+ktSIGs$} z`u9pIle1@%S^bA0lU)qjv1B@#norsK!)Cvq$mWu|qTXOnU$7}qQT4l3ooGML-(}TB z1*vgH6Wh=k<_!9VIfJeLd?Ye$99Dmpf`=IA&QR<)3_3`Ib*#+d!DrsvKcPh1X#Yxyu~!po{_y?;y7J5bB_lcs-J9a$d;cs`L@et;AM%PM;R EU&_7{DF6Tf literal 0 HcmV?d00001 diff --git a/hexdump/Release/hexdump.map b/hexdump/Release/hexdump.map new file mode 100644 index 0000000..da7c105 --- /dev/null +++ b/hexdump/Release/hexdump.map @@ -0,0 +1,199 @@ + +IEEE 695 OMF Linker Version 6.25 (19073001) +Copyright (C) 1999-2008 Zilog, Inc. All Rights Reserved + +LINK MAP: + +DATE: Sun Jun 11 21:44:53 2023 +PROCESSOR: assembler +FILES: .\init.obj .\main.obj .\output.obj + + +COMMAND LIST: +============= +/* Linker Command File - hexdump Release */ + +/* Generated by: */ +/* ZDS II - eZ80Acclaim! 5.3.5 (Build 23020901) */ +/* IDE component: d:5.3.0:23020901 */ +/* assembler options */ +/* -define:_EZ80ACCLAIM!=1 -define:_SIMULATE=1 */ +/* -include:"\"..;D:\agon\MOS\src;C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\include\std;C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\include\zilog\"" */ +/* -list -NOlistmac -name -pagelen:0 -pagewidth:80 -quiet -NOsdiopt */ +/* -warn -NOdebug -NOigcase -cpu:eZ80F92 */ + +-FORMAT=OMF695,INTEL32 +-map -maxhexlen=64 -quiet -warnoverlap -xref -unresolved=fatal +-sort NAME=ascending -warn -NOdebug -NOigcase + +RANGE ROM $000000 : $01FFFF +RANGE RAM $040000 : $0BFFFF +RANGE EXTIO $000000 : $00FFFF +RANGE INTIO $000000 : $0000FF + +DEFINE __crtl = 0 +DEFINE __CS0_LBR_INIT_PARAM = $02 +DEFINE __CS0_UBR_INIT_PARAM = $09 +DEFINE __CS0_CTL_INIT_PARAM = $08 +DEFINE __CS0_BMC_INIT_PARAM = $01 +DEFINE __CS1_LBR_INIT_PARAM = $c0 +DEFINE __CS1_UBR_INIT_PARAM = $c7 +DEFINE __CS1_CTL_INIT_PARAM = $28 +DEFINE __CS1_BMC_INIT_PARAM = $02 +DEFINE __CS2_LBR_INIT_PARAM = $80 +DEFINE __CS2_UBR_INIT_PARAM = $bf +DEFINE __CS2_CTL_INIT_PARAM = $28 +DEFINE __CS2_BMC_INIT_PARAM = $81 +DEFINE __CS3_LBR_INIT_PARAM = $00 +DEFINE __CS3_UBR_INIT_PARAM = $00 +DEFINE __CS3_CTL_INIT_PARAM = $00 +DEFINE __CS3_BMC_INIT_PARAM = $02 +DEFINE __RAM_CTL_INIT_PARAM = $80 +DEFINE __RAM_ADDR_U_INIT_PARAM = $FF +DEFINE __FLASH_CTL_INIT_PARAM = $28 +DEFINE __FLASH_ADDR_U_INIT_PARAM = $00 + +define _SYS_CLK_FREQ = 18432000 + + +/* additional user-defined directives */ +SEQUENCE __VECTORS, CODE, LORAM +COPY __VECTORS RAM +COPY CODE RAM +COPY LORAM RAM + +/* end additional user-defined directives */ + +"D:\agon\agon-projects-main\ASM\hexdump\Release\hexdump"= ".\init.obj", ".\main.obj", ".\output.obj" + + +SPACE ALLOCATION: +================= + +Space Base Top Size Used Unused +------------------ ----------- ----------- --------- --------- --------- +RAM D:040000 D:0403BB 80000H 3BCH 7FC44H + ( 524288 956 523332) +ROM C:000000 C:0003BB 20000H 3BCH 1FC44H + ( 131072 956 130116) + + +SEGMENTS WITHIN SPACE: +====================== + +RAM Type Base Top Size +------------------ ------------------- ----------- ----------- --------- +__VECTORS * segment copy * D:040000 D:040144 145h +CODE * segment copy * D:040145 D:040350 20ch +LORAM * segment copy * D:040351 D:0403BB 6bh + + +ROM Type Base Top Size +------------------ ------------------- ----------- ----------- --------- +__VECTORS normal data C:000000 C:000144 145h +CODE normal data C:000145 C:000350 20ch +LORAM normal data C:000351 C:0003BB 6bh + +SEGMENTS WITHIN MODULES: +======================== + +Module: D:\agon\agon-projects-main\ASM\hexdump\init.asm (File: init.obj) Version: 1:0 06/11/2023 21:44:53 + + Name Base Top Size + --------------------------------------- ----------- ----------- --------- + Segment: __VECTORS C:000000 C:000144 145h + + +Module: D:\agon\agon-projects-main\ASM\hexdump\main.asm (File: main.obj) Version: 1:0 06/11/2023 21:44:53 + + Name Base Top Size + --------------------------------------- ----------- ----------- --------- + Segment: CODE C:000145 C:000328 1e4h + Segment: LORAM C:000351 C:0003BB 6bh + + +Module: D:\agon\agon-projects-main\ASM\hexdump\output.asm (File: output.obj) Version: 1:0 06/11/2023 21:44:53 + + Name Base Top Size + --------------------------------------- ----------- ----------- --------- + Segment: CODE C:000329 C:000350 28h + +EXTERNAL DEFINITIONS: +===================== + +Symbol Address Module Segment +-------------------------------- ----------- --------------- -------------------------------- +__crtl 00000000 (User Defined) +__CS0_BMC_INIT_PARAM 00000001 (User Defined) +__CS0_CTL_INIT_PARAM 00000008 (User Defined) +__CS0_LBR_INIT_PARAM 00000002 (User Defined) +__CS0_UBR_INIT_PARAM 00000009 (User Defined) +__CS1_BMC_INIT_PARAM 00000002 (User Defined) +__CS1_CTL_INIT_PARAM 00000028 (User Defined) +__CS1_LBR_INIT_PARAM 000000C0 (User Defined) +__CS1_UBR_INIT_PARAM 000000C7 (User Defined) +__CS2_BMC_INIT_PARAM 00000081 (User Defined) +__CS2_CTL_INIT_PARAM 00000028 (User Defined) +__CS2_LBR_INIT_PARAM 00000080 (User Defined) +__CS2_UBR_INIT_PARAM 000000BF (User Defined) +__CS3_BMC_INIT_PARAM 00000002 (User Defined) +__CS3_CTL_INIT_PARAM 00000000 (User Defined) +__CS3_LBR_INIT_PARAM 00000000 (User Defined) +__CS3_UBR_INIT_PARAM 00000000 (User Defined) +__FLASH_ADDR_U_INIT_PARAM 00000000 (User Defined) +__FLASH_CTL_INIT_PARAM 00000028 (User Defined) +__RAM_ADDR_U_INIT_PARAM 000000FF (User Defined) +__RAM_CTL_INIT_PARAM 00000080 (User Defined) +_main C:000149 main CODE +_SYS_CLK_FREQ 01194000 (User Defined) +Print_Hex16 C:000339 output CODE +Print_Hex24 C:000329 output CODE +Print_Hex8 C:00033E output CODE + +26 external symbol(s). + +SYMBOL CROSS REFERENCE: +======================= +Name Use Module +--------------------------------- ----------- ------------------------- +__crtl Defined LINKER +__CS0_BMC_INIT_PARAM Defined LINKER +__CS0_CTL_INIT_PARAM Defined LINKER +__CS0_LBR_INIT_PARAM Defined LINKER +__CS0_UBR_INIT_PARAM Defined LINKER +__CS1_BMC_INIT_PARAM Defined LINKER +__CS1_CTL_INIT_PARAM Defined LINKER +__CS1_LBR_INIT_PARAM Defined LINKER +__CS1_UBR_INIT_PARAM Defined LINKER +__CS2_BMC_INIT_PARAM Defined LINKER +__CS2_CTL_INIT_PARAM Defined LINKER +__CS2_LBR_INIT_PARAM Defined LINKER +__CS2_UBR_INIT_PARAM Defined LINKER +__CS3_BMC_INIT_PARAM Defined LINKER +__CS3_CTL_INIT_PARAM Defined LINKER +__CS3_LBR_INIT_PARAM Defined LINKER +__CS3_UBR_INIT_PARAM Defined LINKER +__FLASH_ADDR_U_INIT_PARAM Defined LINKER +__FLASH_CTL_INIT_PARAM Defined LINKER +__RAM_ADDR_U_INIT_PARAM Defined LINKER +__RAM_CTL_INIT_PARAM Defined LINKER +_main Defined D:\agon\agon-projects-main\ASM\hexdump\main.asm + Referenced D:\agon\agon-projects-main\ASM\hexdump\init.asm +_SYS_CLK_FREQ Defined LINKER +Print_Hex16 Defined D:\agon\agon-projects-main\ASM\hexdump\output.asm +Print_Hex24 Defined D:\agon\agon-projects-main\ASM\hexdump\output.asm + Referenced D:\agon\agon-projects-main\ASM\hexdump\main.asm +Print_Hex8 Defined D:\agon\agon-projects-main\ASM\hexdump\output.asm + Referenced D:\agon\agon-projects-main\ASM\hexdump\main.asm + +OUTPUT CHECKSUM +=============== +hexdump.hex 01235B +hexdump.lod 01235B + + + +END OF LINK MAP: +================ +0 Errors +0 Warnings diff --git a/hexdump/Release/hexdump_Release.linkcmd b/hexdump/Release/hexdump_Release.linkcmd new file mode 100644 index 0000000..1aa33c6 --- /dev/null +++ b/hexdump/Release/hexdump_Release.linkcmd @@ -0,0 +1,58 @@ +/* Linker Command File - hexdump Release */ + +/* Generated by: */ +/* ZDS II - eZ80Acclaim! 5.3.5 (Build 23020901) */ +/* IDE component: d:5.3.0:23020901 */ +/* assembler options */ +/* -define:_EZ80ACCLAIM!=1 -define:_SIMULATE=1 */ +/* -include:"\"..;D:\agon\MOS\src;C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\include\std;C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\include\zilog\"" */ +/* -list -NOlistmac -name -pagelen:0 -pagewidth:80 -quiet -NOsdiopt */ +/* -warn -NOdebug -NOigcase -cpu:eZ80F92 */ + +-FORMAT=OMF695,INTEL32 +-map -maxhexlen=64 -quiet -warnoverlap -xref -unresolved=fatal +-sort NAME=ascending -warn -NOdebug -NOigcase + +RANGE ROM $000000 : $01FFFF +RANGE RAM $040000 : $0BFFFF +RANGE EXTIO $000000 : $00FFFF +RANGE INTIO $000000 : $0000FF + +DEFINE __crtl = 0 +DEFINE __CS0_LBR_INIT_PARAM = $02 +DEFINE __CS0_UBR_INIT_PARAM = $09 +DEFINE __CS0_CTL_INIT_PARAM = $08 +DEFINE __CS0_BMC_INIT_PARAM = $01 +DEFINE __CS1_LBR_INIT_PARAM = $c0 +DEFINE __CS1_UBR_INIT_PARAM = $c7 +DEFINE __CS1_CTL_INIT_PARAM = $28 +DEFINE __CS1_BMC_INIT_PARAM = $02 +DEFINE __CS2_LBR_INIT_PARAM = $80 +DEFINE __CS2_UBR_INIT_PARAM = $bf +DEFINE __CS2_CTL_INIT_PARAM = $28 +DEFINE __CS2_BMC_INIT_PARAM = $81 +DEFINE __CS3_LBR_INIT_PARAM = $00 +DEFINE __CS3_UBR_INIT_PARAM = $00 +DEFINE __CS3_CTL_INIT_PARAM = $00 +DEFINE __CS3_BMC_INIT_PARAM = $02 +DEFINE __RAM_CTL_INIT_PARAM = $80 +DEFINE __RAM_ADDR_U_INIT_PARAM = $FF +DEFINE __FLASH_CTL_INIT_PARAM = $28 +DEFINE __FLASH_ADDR_U_INIT_PARAM = $00 + +define _SYS_CLK_FREQ = 18432000 + + +/* additional user-defined directives */ +SEQUENCE __VECTORS, CODE, LORAM +COPY __VECTORS RAM +COPY CODE RAM +COPY LORAM RAM + +/* end additional user-defined directives */ + +"D:\agon\agon-projects-main\ASM\hexdump\Release\hexdump"= \ + ".\init.obj", \ + ".\main.obj", \ + ".\output.obj" + diff --git a/hexdump/Release/hexdump_Release.mak b/hexdump/Release/hexdump_Release.mak new file mode 100644 index 0000000..b86de02 --- /dev/null +++ b/hexdump/Release/hexdump_Release.mak @@ -0,0 +1,129 @@ +SHELL = cmd.exe + +# +# ZDS II Make File - hexdump project, Release configuration +# +# Generated by: ZDS II - eZ80Acclaim! 5.3.5 (Build 23020901) +# IDE component: d:5.3.0:23020901 +# Install Path: C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\ +# + +RM = del + +# ZDS base directory +ZDSDIR = C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5 +ZDSDIR_ESCSPACE = C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5 + +# ZDS bin directory +BIN = $(ZDSDIR)\bin + +# ZDS include base directory +INCLUDE = C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\include +INCLUDE_ESCSPACE = C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\include + +# ZTP base directory +ZTPDIR = C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\ZTP2.5.1 +ZTPDIR_ESCSPACE = C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\ZTP2.5.1 + +# project directory +PRJDIR = D:\agon\agon-projects-main\ASM\hexdump +PRJDIR_ESCSPACE = D:\agon\agon-projects-main\ASM\hexdump + +# intermediate files directory +WORKDIR = D:\agon\agon-projects-main\ASM\hexdump\Release +WORKDIR_ESCSPACE = D:\agon\agon-projects-main\ASM\hexdump\Release + +# output files directory +OUTDIR = D:\agon\agon-projects-main\ASM\hexdump\Release\ +OUTDIR_ESCSPACE = D:\agon\agon-projects-main\ASM\hexdump\Release\ + +# tools +CC = @"$(BIN)\eZ80cc" +AS = @"$(BIN)\eZ80asm" +LD = @"$(BIN)\eZ80link" +AR = @"$(BIN)\eZ80lib" +WEBTOC = @"$(BIN)\mkwebpage" + +ASFLAGS = \ +-define:_EZ80ACCLAIM!=1 -define:_SIMULATE=1 \ +-include:"\"..;D:\agon\MOS\src;C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\include\std;C:\Zilog\ZDSII_eZ80Acclaim!_5.3.5\include\zilog\"" \ +-list -NOlistmac -name -pagelen:0 -pagewidth:80 -quiet -NOsdiopt \ +-warn -NOdebug -NOigcase -cpu:eZ80F92 + +LDFLAGS = @.\hexdump_Release.linkcmd +build: hexdump relist + +buildall: clean hexdump relist + +relink: deltarget hexdump + +deltarget: + @if exist "$(WORKDIR)\hexdump.lod" \ + $(RM) "$(WORKDIR)\hexdump.lod" + @if exist "$(WORKDIR)\hexdump.hex" \ + $(RM) "$(WORKDIR)\hexdump.hex" + @if exist "$(WORKDIR)\hexdump.map" \ + $(RM) "$(WORKDIR)\hexdump.map" + +clean: + @if exist "$(WORKDIR)\hexdump.lod" \ + $(RM) "$(WORKDIR)\hexdump.lod" + @if exist "$(WORKDIR)\hexdump.hex" \ + $(RM) "$(WORKDIR)\hexdump.hex" + @if exist "$(WORKDIR)\hexdump.map" \ + $(RM) "$(WORKDIR)\hexdump.map" + @if exist "$(WORKDIR)\init.obj" \ + $(RM) "$(WORKDIR)\init.obj" + @if exist "$(WORKDIR)\init.lis" \ + $(RM) "$(WORKDIR)\init.lis" + @if exist "$(WORKDIR)\init.lst" \ + $(RM) "$(WORKDIR)\init.lst" + @if exist "$(WORKDIR)\main.obj" \ + $(RM) "$(WORKDIR)\main.obj" + @if exist "$(WORKDIR)\main.lis" \ + $(RM) "$(WORKDIR)\main.lis" + @if exist "$(WORKDIR)\main.lst" \ + $(RM) "$(WORKDIR)\main.lst" + @if exist "$(WORKDIR)\output.obj" \ + $(RM) "$(WORKDIR)\output.obj" + @if exist "$(WORKDIR)\output.lis" \ + $(RM) "$(WORKDIR)\output.lis" + @if exist "$(WORKDIR)\output.lst" \ + $(RM) "$(WORKDIR)\output.lst" + +relist: + $(AS) $(ASFLAGS) -relist:"D:\agon\agon-projects-main\ASM\hexdump\Release\hexdump.map" \ + D:\agon\agon-projects-main\ASM\hexdump\init.asm + $(AS) $(ASFLAGS) -relist:"D:\agon\agon-projects-main\ASM\hexdump\Release\hexdump.map" \ + D:\agon\agon-projects-main\ASM\hexdump\main.asm + $(AS) $(ASFLAGS) -relist:"D:\agon\agon-projects-main\ASM\hexdump\Release\hexdump.map" \ + D:\agon\agon-projects-main\ASM\hexdump\output.asm + +# pre-4.11.0 compatibility +rebuildall: buildall + +LIBS = + +OBJS = \ + $(WORKDIR_ESCSPACE)\init.obj \ + $(WORKDIR_ESCSPACE)\main.obj \ + $(WORKDIR_ESCSPACE)\output.obj + +hexdump: $(OBJS) + $(LD) $(LDFLAGS) + +$(WORKDIR_ESCSPACE)\init.obj : \ + $(PRJDIR_ESCSPACE)\init.asm \ + $(PRJDIR_ESCSPACE)\equs.inc + $(AS) $(ASFLAGS) "$(PRJDIR)\init.asm" + +$(WORKDIR_ESCSPACE)\main.obj : \ + $(PRJDIR_ESCSPACE)\main.asm \ + $(PRJDIR_ESCSPACE)\equs.inc \ + $(PRJDIR_ESCSPACE)\mos_api.inc + $(AS) $(ASFLAGS) "$(PRJDIR)\main.asm" + +$(WORKDIR_ESCSPACE)\output.obj : \ + $(PRJDIR_ESCSPACE)\output.asm + $(AS) $(ASFLAGS) "$(PRJDIR)\output.asm" + diff --git a/hexdump/Release/init.lst b/hexdump/Release/init.lst new file mode 100644 index 0000000..68e6371 --- /dev/null +++ b/hexdump/Release/init.lst @@ -0,0 +1,308 @@ +Zilog eZ80 Macro Assembler Version 4.3 (19073001) RELISTED11-Jun-23 21:44:53 page: 1 + + +PC Object I Line Source + A 1 ; + A 2 ; Title: Memory Dump - Initialisation Code + A 3 ; Author: Dean Belfield + A 4 ; Created: 15/11/2022 + A 5 ; Last Updated: 23/12/2022 + A 6 ; + A 7 ; Modinfo: + A 8 ; 23/12/2022: Added parameter parsing code + A 9 + A 10 SEGMENT __VECTORS + A 11 + A 12 XREF _main + A 13 + A 14 .ASSUME ADL = 0 + A 15 + B 0 INCLUDE "equs.inc" + B 1 ; + B 2 ; Title: Memory Dump - Equs + B 3 ; Author: Dean Belfield + B 4 ; Created: 15/11/2022 + B 5 ; Last Updated: 15/11/2022 + B 6 ; + B 7 ; Modinfo: + B 8 + 0000FF00 B 9 RAM_Top: EQU 0FF00h + 00000000 B 10 Stack_Top: EQU 00000h ; Stack at top + B 11 + B 12 ; For GPIO + B 13 ; PA not available on eZ80L92 + B 14 ; + 00000096 B 15 PA_DR: EQU 96h + 00000097 B 16 PA_DDR: EQU 97h + 00000098 B 17 PA_ALT1: EQU 98h + 00000099 B 18 PA_ALT2: EQU 99h + 0000009A B 19 PB_DR: EQU 9Ah + 0000009B B 20 PB_DDR: EQU 9Bh + 0000009C B 21 PB_ALT1: EQU 9Ch + 0000009D B 22 PB_ALT2: EQU 9Dh + 0000009E B 23 PC_DR: EQU 9Eh + 0000009F B 24 PC_DDR: EQU 9Fh + 000000A0 B 25 PC_ALT1: EQU A0h + 000000A1 B 26 PC_ALT2: EQU A1h + 000000A2 B 27 PD_DR: EQU A2h + 000000A3 B 28 PD_DDR: EQU A3h + 000000A4 B 29 PD_ALT1: EQU A4h + 000000A5 B 30 PD_ALT2: EQU A5h + B 31 + 00000000 B 32 GPIOMODE_OUT: EQU 0 ; Output + 00000001 B 33 GPIOMODE_IN: EQU 1 ; Input + 00000002 B 34 GPIOMODE_DIO: EQU 2 ; Open Drain IO + 00000003 B 35 GPIOMODE_SIO: EQU 3 ; Open Source I + 00000004 B 36 GPIOMODE_INTD: EQU 4 ; Interrupt, Du + 00000005 B 37 GPIOMODE_ALTF: EQU 5; ; Alt Function + 00000006 B 38 GPIOMODE_INTAL: EQU 6 ; Interrupt, Ac + 00000007 B 39 GPIOMODE_INTAH: EQU 7 ; Interrupt, Ac + 00000008 B 40 GPIOMODE_INTFE: EQU 8 ; Interrupt, Fa + 00000009 B 41 GPIOMODE_INTRE: EQU 9 ; Interrupt, Ri + B 42 + B 43 ; For serial.asm + B 44 ; + 016E3600 B 45 BASE_CLOCK EQU 24000000 ; It's actually + B 46 + 00000003 B 47 BAUD_500000 EQU BASE_CLOCK / (16 * 500000) + 00000006 B 48 BAUD_250000 EQU BASE_CLOCK / (16 * 250000) + 0000000C B 49 BAUD_125000 EQU BASE_CLOCK / (16 * 125000) + 0000004E B 50 BAUD_19200 EQU BASE_CLOCK / (16 * 19200) + B 51 + B 52 ; For interrupts.asm + B 53 ; + B 54 + B 55 ;UARTs + B 56 ; + 00000018 B 57 UART0_IVECT EQU 18h + 0000001A B 58 UART1_IVECT EQU 1Ah + B 59 + B 60 ;Ports + B 61 ; + 00000030 B 62 PB0_IVECT EQU 30h ; AGON ITRP Int + 00000032 B 63 PB1_IVECT EQU 32h ; AGON VBLANK Inter + 00000034 B 64 PB2_IVECT EQU 34h + 00000036 B 65 PB3_IVECT EQU 36h + 00000038 B 66 PB4_IVECT EQU 38h + 0000003A B 67 PB5_IVECT EQU 3Ah + 0000003C B 68 PB6_IVECT EQU 3Ch + 0000003E B 69 PB7_IVECT EQU 3Eh + B 70 + 00000040 B 71 PC0_IVECT EQU 40h + 00000042 B 72 PC1_IVECT EQU 42h + 00000044 B 73 PC2_IVECT EQU 44h + 00000046 B 74 PC3_IVECT EQU 46h + 00000048 B 75 PC4_IVECT EQU 48h + 0000004A B 76 PC5_IVECT EQU 4Ah + 0000004C B 77 PC6_IVECT EQU 4Ch + 0000004E B 78 PC7_IVECT EQU 4Eh + B 79 + 00000050 B 80 PD0_IVECT EQU 50h + 00000052 B 81 PD1_IVECT EQU 52h + 00000054 B 82 PD2_IVECT EQU 54h + 00000056 B 83 PD3_IVECT EQU 56h + 00000058 B 84 PD4_IVECT EQU 58h + 0000005A B 85 PD5_IVECT EQU 5Ah + 0000005C B 86 PD6_IVECT EQU 5Ch + 0000005E B 87 PD7_IVECT EQU 5Eh + B 88 + B 89 ; Originally in main.asm + B 90 ; + 0000000D B 91 CR: EQU 0DH + 0000000A B 92 LF: EQU 0AH + 0000001B B 93 ESC: EQU 1BH + A 17 + 00000010 A 18 argv_ptrs_max: EQU 16 ; Maximum n + A 19 + A 20 ; + A 21 ; Start in mixed mode. Assumes MBASE is set to + A 22 ; +000000 C3 51 00 A 23 JP _start ; Jump to start +000003 A 24 DS 5 + A 25 +000008 49CF A 26 RST_08: RST.LIS 08h ; API call +00000A C9 A 27 RET +00000B A 28 DS 5 + A 29 +000010 49D7 A 30 RST_10: RST.LIS 10h ; Output +000012 C9 A 31 RET +000013 A 32 DS 5 + A 33 +000018 A 34 RST_18: DS 8 +000020 A 35 RST_20: DS 8 +000028 A 36 RST_28: DS 8 +000030 A 37 RST_30: DS 8 + A 38 ; + A 39 ; The NMI interrupt vector (not currently used + A 40 ; +000038 FB A 41 RST_38: EI +000039 ED4D A 42 RETI + A 43 ; + A 44 ; The header stuff is from byte 64 onwards + A 45 ; + A 46 ALIGN 64 + A 47 +000040 4D4F53 A 48 DB "MOS" ; Flag for +000043 00 A 49 DB 00h ; MOS header ve +000044 00 A 50 DB 00h ; Flag for run + A 51 +000045 48455844 554D502E A 52 _exec_name: DB "HEXDUMP.BIN", 0 ; T +00004D 42494E00 + A 53 + A 54 ; + A 55 ; And the code follows on immediately after the + A 56 ; +000051 5BFDE5 A 57 _start: PUSH.LIL IY ; Prese + A 58 +000054 FD210000 A 59 LD IY, 0 ; Preserve +000058 FD39 A 60 ADD IY, SP +00005A 5BFDE5 A 61 PUSH.LIL IY +00005D 310080 A 62 LD SP, 8000h ; And set t + A 63 +000060 F5 A 64 PUSH AF ; Preserve +000061 5BC5 A 65 PUSH.LIL BC +000063 5BD5 A 66 PUSH.LIL DE +000065 5BDDE5 A 67 PUSH.LIL IX + A 68 +000068 ED6E A 69 LD A, MB ; Segment b +00006A DD21 15 01 A 70 LD IX, argv_ptrs ; The a +00006E CD 01 01 A 71 CALL _set_aix24 ; Conve +000071 5BDDE5 A 72 PUSH.LIL IX +000074 CD 91 00 A 73 CALL _parse_params ; P +000077 5BDDE1 A 74 POP.LIL IX ; IX: argv +00007A 0600 A 75 LD B, 0 ; C: argc +00007C CD 49 01 A 76 CALL _main ; Start + A 77 +00007F 5BDDE1 A 78 POP.LIL IX ; Restore t +000082 5BD1 A 79 POP.LIL DE +000084 5BC1 A 80 POP.LIL BC +000086 F1 A 81 POP AF + A 82 +000087 5BFDE1 A 83 POP.LIL IY ; Get the p +00008A FDF9 A 84 LD SP, IY ; Restore t + A 85 +00008C 5BFDE1 A 86 POP.LIL IY ; Restore I +00008F 49C9 A 87 RET.L ; Return to + A 88 + A 89 ; Parse the parameter string into a C array + A 90 ; Parameters + A 91 ; - A: Segment base + A 92 ; - HLU: Address of parameter string + A 93 ; - IXU: Address for array pointer storage + A 94 ; Returns: + A 95 ; - C: Number of parameters parsed + A 96 ; +000091 01 45 00 A 97 _parse_params: LD BC, _exec_name +000094 CD EF 00 A 98 CALL _set_abc24 ; Conve +000097 5BDD0F00 A 99 LD.LIL (IX+0), BC ; ARGV[ +00009B 5BDD23 A 100 INC.LIL IX +00009E 5BDD23 A 101 INC.LIL IX +0000A1 5BDD23 A 102 INC.LIL IX +0000A4 CD E6 00 A 103 CALL _skip_spaces ; S + A 104 ; +0000A7 010100 A 105 LD BC, 1 ; C: ARGC = +0000AA 060F A 106 LD B, argv_ptrs_max - 1 ; B + A 107 ; +0000AC C5 A 108 _parse_params_1: PUSH BC ; S +0000AD 5BE5 A 109 PUSH.LIL HL ; Stack sta +0000AF CD D5 00 A 110 CALL _get_token ; Get t +0000B2 79 A 111 LD A, C ; A: Length +0000B3 5BD1 A 112 POP.LIL DE ; Start add +0000B5 C1 A 113 POP BC ; ARGC +0000B6 B7 A 114 OR A ; Check for A=0 +0000B7 C8 A 115 RET Z + A 116 ; +0000B8 5BDD1F00 A 117 LD.LIL (IX+0), DE ; Store +0000BC 5BE5 A 118 PUSH.LIL HL ; DE=HL +0000BE 5BD1 A 119 POP.LIL DE +0000C0 CD E6 00 A 120 CALL _skip_spaces ; A +0000C3 AF A 121 XOR A +0000C4 5B12 A 122 LD.LIL (DE), A ; Zero- +0000C6 5BDD23 A 123 INC.LIL IX +0000C9 5BDD23 A 124 INC.LIL IX +0000CC 5BDD23 A 125 INC.LIL IX ; Advance t +0000CF 0C A 126 INC C ; Increment ARG +0000D0 79 A 127 LD A, C ; Check for +0000D1 B8 A 128 CP B +0000D2 38 D8 A 129 JR C, _parse_params_1 ; And l +0000D4 C9 A 130 RET + A 131 + A 132 ; Get the next token + A 133 ; Parameters: + A 134 ; - HL: Address of parameter string + A 135 ; Returns: + A 136 ; - HL: Address of first character after token + A 137 ; - C: Length of token (in characters) + A 138 ; +0000D5 0E00 A 139 _get_token: LD C, 0 ; Initi +0000D7 5B7E A 140 $$: LD.LIL A, (HL) ; Get t +0000D9 B7 A 141 OR A ; Exit if 0 (en +0000DA C8 A 142 RET Z +0000DB FE0D A 143 CP 13 ; Exit if CR (e +0000DD C8 A 144 RET Z +0000DE FE20 A 145 CP ' ' ; Exit if space +0000E0 C8 A 146 RET Z +0000E1 5B23 A 147 INC.LIL HL ; Advance t +0000E3 0C A 148 INC C ; Increment +0000E4 18 F1 A 149 JR $B + A 150 + A 151 ; Skip spaces in the parameter string + A 152 ; Parameters: + A 153 ; - HL: Address of parameter string + A 154 ; Returns: + A 155 ; - HL: Address of next none-space character + A 156 ; F: Z if at end of string, otherwise NZ if + A 157 ; +0000E6 5B7E A 158 _skip_spaces: LD.LIL A, (HL) +0000E8 FE20 A 159 CP ' ' ; Exit if not s +0000EA C0 A 160 RET NZ +0000EB 5B23 A 161 INC.LIL HL ; Advance t +0000ED 18 F7 A 162 JR _skip_spaces ; Incre + A 163 + A 164 ; Set the MSB of BC (U) to A + A 165 ; Parameters: + A 166 ; - BC: 16-bit address + A 167 ; - A: Value to stick in U of BC + A 168 ; Returns: + A 169 ; - BCU + A 170 ; +0000EF 5BE5 A 171 _set_abc24: PUSH.LIL HL ; Prese +0000F1 5BC5 A 172 PUSH.LIL BC ; Stick BC +0000F3 5B210200 00 A 173 LD.LIL HL, 2 ; HL: S +0000F8 5B39 A 174 ADD.LIL HL, SP +0000FA 5B77 A 175 LD.LIL (HL), A ; Store +0000FC 5BC1 A 176 POP.LIL BC ; Fetch amm +0000FE 5BE1 A 177 POP.LIL HL ; Restore H +000100 C9 A 178 RET + A 179 + A 180 ; Set the MSB of BC (U) to A + A 181 ; Parameters: + A 182 ; - IX: 16-bit address + A 183 ; - A: Value to stick in U of BC + A 184 ; Returns: + A 185 ; - IXU + A 186 ; +000101 5BDDE5 A 187 _set_aix24: PUSH.LIL IX ; Stick +000104 5BDD2102 0000 A 188 LD.LIL IX, 2 ; IX: S +00010A 5BDD39 A 189 ADD.LIL IX, SP +00010D 5BDD7700 A 190 LD.LIL (IX), A ; Store +000111 5BDDE1 A 191 POP.LIL IX ; Fetch amm +000114 C9 A 192 RET + A 193 + A 194 ; Storage for the argv array pointers + A 195 ; +000115 000000 000000 A 196 argv_ptrs: BLKP argv_ptrs_max, 0 +00011B 000000 000000 +000121 000000 000000 +000127 000000 000000 +00012D 000000 000000 +000133 000000 000000 +000139 000000 000000 +00013F 000000 000000 + A 197 + A 198 END + + +Errors: 0 +Warnings: 0 +Lines Assembled: 292 diff --git a/hexdump/Release/init.obj b/hexdump/Release/init.obj new file mode 100644 index 0000000000000000000000000000000000000000..bfaca71876735bc09df66510b3d87ff863bf5e04 GIT binary patch literal 1243 zcmZ`(O=}ZT6n$@IGI_<14uwK?CKOs1w$`+TMmJ59fLSEbBuXKH5;bVWq@}6UZqyWi zKwSC*y4Ib#v6iG@7me0ZrU(T)yd($)lZ6xssopyuu@PLnymQVy_rCk?%;alNDwj)V zZaqjZUi4p1rtZ#X^`GH|#rgZ`+e^9OOlmHh^u|KTd+A4a9%dGjbJ@A2kyI}8or&9; zN}dryo@gqCUFy?R0rxAKD&jt-sS?JCrrL0Sp{cUT?HK>k7?i@{vB_q6kPHfqAtat= zd58=N70Oxh-Dg_3URW#Se-~b{b&IjWTbZqEpD09GVXXtW68y;7mcbP(0007NC*ZIG z9pJQ-4mfWq9WZJs9WZGr061%Lr5-X)o+_->#ZV+>Fdr~V4D3IF1AwKgff;{Yx)HiI zQkSNKVbcaT=8iw8Xb;uQ&V8wlEJsLn=@x%_axWQQyTL*vpmkEMfoKb8A z24E$dtgF-fkFK~*O@lLW&`a?411EmWzN_6?NUgpog;~nIoZ<8;=0Ng$-3dsoK32fD z!x`M-HD@0<9D5EbK&me5^UVMMJoXZNeJ4898)m0DTjA^tXOnCn-bt>U#hQ=JGnC^q zc$9MN)VIU{#{>tA5k0#69w5jLb_4)>*@Vtq0%2Ik18W)92CPFYuRl}h+$AXRDgpE0 zJ(hKdh9jje;`gb4Osf?ZD2drdyoe_^6Aj+(n!9w+1E8@0{ipF&Ht z1!m&G2o1C(TQH0$*b>BOBt(5JDn`8_>aPmLl06oW#sa=LA+#n?ZC4;wxmc2X5r2RX zp(cYQld1?(9O|JYf+UhEEtYy_XKzAkBpO4VPHDRonygC2k~kd$jn*XaN~CIobiX(5 LMac$|jU4^~a&Rhz literal 0 HcmV?d00001 diff --git a/hexdump/Release/main.lst b/hexdump/Release/main.lst new file mode 100644 index 0000000..465198e --- /dev/null +++ b/hexdump/Release/main.lst @@ -0,0 +1,647 @@ +Zilog eZ80 Macro Assembler Version 4.3 (19073001) RELISTED11-Jun-23 21:44:53 page: 1 + + +PC Object I Line Source + A 1 ; HEXDUMP utility + A 2 ; + A 3 ; + A 4 ; Written Agon native by Shawn Sijnstra + A 5 ; + A 6 ; Notable changes for reference: + A 7 ; required colons on all labels + A 8 ; labels are case sensitive + A 9 ; code is a reserved word and can't be used as + A 10 ; numeric evaluations are done differently - ch + A 11 ; reserved word INCLUDE needs to be in upper ca + A 12 ; assembly source MUST be .asm, can't use e.g. + A 13 ; supports defb as a synonym for db, but NOT de + A 14 ; labels can't start with @ + A 15 ; + A 16 ; DESIGN OF WIDTH: + A 17 ; 6 chars for current byte + A 18 ; dddddd: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX | + A 19 + A 20 + A 21 .ASSUME ADL = 0 + A 22 + B 0 INCLUDE "equs.inc" + B 1 ; + B 2 ; Title: Memory Dump - Equs + B 3 ; Author: Dean Belfield + B 4 ; Created: 15/11/2022 + B 5 ; Last Updated: 15/11/2022 + B 6 ; + B 7 ; Modinfo: + B 8 + 0000FF00 B 9 RAM_Top: EQU 0FF00h + 00000000 B 10 Stack_Top: EQU 00000h ; Stack at top + B 11 + B 12 ; For GPIO + B 13 ; PA not available on eZ80L92 + B 14 ; + 00000096 B 15 PA_DR: EQU 96h + 00000097 B 16 PA_DDR: EQU 97h + 00000098 B 17 PA_ALT1: EQU 98h + 00000099 B 18 PA_ALT2: EQU 99h + 0000009A B 19 PB_DR: EQU 9Ah + 0000009B B 20 PB_DDR: EQU 9Bh + 0000009C B 21 PB_ALT1: EQU 9Ch + 0000009D B 22 PB_ALT2: EQU 9Dh + 0000009E B 23 PC_DR: EQU 9Eh + 0000009F B 24 PC_DDR: EQU 9Fh + 000000A0 B 25 PC_ALT1: EQU A0h + 000000A1 B 26 PC_ALT2: EQU A1h + 000000A2 B 27 PD_DR: EQU A2h + 000000A3 B 28 PD_DDR: EQU A3h + 000000A4 B 29 PD_ALT1: EQU A4h + 000000A5 B 30 PD_ALT2: EQU A5h + B 31 + 00000000 B 32 GPIOMODE_OUT: EQU 0 ; Output + 00000001 B 33 GPIOMODE_IN: EQU 1 ; Input + 00000002 B 34 GPIOMODE_DIO: EQU 2 ; Open Drain IO + 00000003 B 35 GPIOMODE_SIO: EQU 3 ; Open Source I + 00000004 B 36 GPIOMODE_INTD: EQU 4 ; Interrupt, Du + 00000005 B 37 GPIOMODE_ALTF: EQU 5; ; Alt Function + 00000006 B 38 GPIOMODE_INTAL: EQU 6 ; Interrupt, Ac + 00000007 B 39 GPIOMODE_INTAH: EQU 7 ; Interrupt, Ac + 00000008 B 40 GPIOMODE_INTFE: EQU 8 ; Interrupt, Fa + 00000009 B 41 GPIOMODE_INTRE: EQU 9 ; Interrupt, Ri + B 42 + B 43 ; For serial.asm + B 44 ; + 016E3600 B 45 BASE_CLOCK EQU 24000000 ; It's actually + B 46 + 00000003 B 47 BAUD_500000 EQU BASE_CLOCK / (16 * 500000) + 00000006 B 48 BAUD_250000 EQU BASE_CLOCK / (16 * 250000) + 0000000C B 49 BAUD_125000 EQU BASE_CLOCK / (16 * 125000) + 0000004E B 50 BAUD_19200 EQU BASE_CLOCK / (16 * 19200) + B 51 + B 52 ; For interrupts.asm + B 53 ; + B 54 + B 55 ;UARTs + B 56 ; + 00000018 B 57 UART0_IVECT EQU 18h + 0000001A B 58 UART1_IVECT EQU 1Ah + B 59 + B 60 ;Ports + B 61 ; + 00000030 B 62 PB0_IVECT EQU 30h ; AGON ITRP Int + 00000032 B 63 PB1_IVECT EQU 32h ; AGON VBLANK Inter + 00000034 B 64 PB2_IVECT EQU 34h + 00000036 B 65 PB3_IVECT EQU 36h + 00000038 B 66 PB4_IVECT EQU 38h + 0000003A B 67 PB5_IVECT EQU 3Ah + 0000003C B 68 PB6_IVECT EQU 3Ch + 0000003E B 69 PB7_IVECT EQU 3Eh + B 70 + 00000040 B 71 PC0_IVECT EQU 40h + 00000042 B 72 PC1_IVECT EQU 42h + 00000044 B 73 PC2_IVECT EQU 44h + 00000046 B 74 PC3_IVECT EQU 46h + 00000048 B 75 PC4_IVECT EQU 48h + 0000004A B 76 PC5_IVECT EQU 4Ah + 0000004C B 77 PC6_IVECT EQU 4Ch + 0000004E B 78 PC7_IVECT EQU 4Eh + B 79 + 00000050 B 80 PD0_IVECT EQU 50h + 00000052 B 81 PD1_IVECT EQU 52h + 00000054 B 82 PD2_IVECT EQU 54h + 00000056 B 83 PD3_IVECT EQU 56h + 00000058 B 84 PD4_IVECT EQU 58h + 0000005A B 85 PD5_IVECT EQU 5Ah + 0000005C B 86 PD6_IVECT EQU 5Ch + 0000005E B 87 PD7_IVECT EQU 5Eh + B 88 + B 89 ; Originally in main.asm + B 90 ; + 0000000D B 91 CR: EQU 0DH + 0000000A B 92 LF: EQU 0AH + 0000001B B 93 ESC: EQU 1BH + B 0 INCLUDE "mos_api.inc" ; In MOS/sr + B 1 ; + B 2 ; Title: AGON MOS - API for user projects + B 3 ; Author: Dean Belfield + B 4 ; Created: 03/08/2022 + B 5 ; Last Updated: 15/04/2023 + B 6 ; + B 7 ; Modinfo: + B 8 ; 05/08/2022: Added mos_feof + B 9 ; 09/08/2022: Added system variables: cursorX + B 10 ; 18/08/2022: Added system variables: scrchar + B 11 ; 05/09/2022: Added mos_ren, vdp_pflag_mode + B 12 ; 24/09/2022: Added mos_getError, mos_mkdir + B 13 ; 13/10/2022: Added mos_oscli + B 14 ; 23/02/2023: Added more sysvars, fixed typo + B 15 ; 04/03/2023: Added sysvar_scrpixelIndex + B 16 ; 08/03/2023: Renamed sysvar_keycode to sysva + B 17 ; 15/03/2023: Added mos_copy, mos_getrtc, mos + B 18 ; 21/03/2023: Added mos_setintvector, sysvars + B 19 ; 22/03/2023: The VDP commands are now indexe + B 20 ; 29/03/2023: Added mos_uopen, mos_uclose, mo + B 21 ; 13/04/2023: Added FatFS file structures (FF + B 22 ; 15/04/2023: Added mos_getfil, mos_fread, mo + B 23 + B 24 ; VDP control (VDU 23, 0, n) + B 25 ; + 00000080 B 26 vdp_gp: EQU 80h + 00000081 B 27 vdp_keycode: EQU 81h + 00000082 B 28 vdp_cursor: EQU 82h + 00000083 B 29 vdp_scrchar: EQU 83h + 00000084 B 30 vdp_scrpixel: EQU 84h + 00000085 B 31 vdp_audio: EQU 85h + 00000086 B 32 vdp_mode: EQU 86h + 00000087 B 33 vdp_rtc: EQU 87h + 00000088 B 34 vdp_keystate: EQU 88h + 000000C0 B 35 vdp_logicalcoords: EQU C0h + 000000FF B 36 vdp_terminalmode: EQU FFh + B 37 + B 38 ; MOS high level functions + B 39 ; + 00000000 B 40 mos_getkey: EQU 00h + 00000001 B 41 mos_load: EQU 01h + 00000002 B 42 mos_save: EQU 02h + 00000003 B 43 mos_cd: EQU 03h + 00000004 B 44 mos_dir: EQU 04h + 00000005 B 45 mos_del: EQU 05h + 00000006 B 46 mos_ren: EQU 06h + 00000007 B 47 mos_mkdir: EQU 07h + 00000008 B 48 mos_sysvars: EQU 08h + 00000009 B 49 mos_editline: EQU 09h + 0000000A B 50 mos_fopen: EQU 0Ah + 0000000B B 51 mos_fclose: EQU 0Bh + 0000000C B 52 mos_fgetc: EQU 0Ch + 0000000D B 53 mos_fputc: EQU 0Dh + 0000000E B 54 mos_feof: EQU 0Eh + 0000000F B 55 mos_getError: EQU 0Fh + 00000010 B 56 mos_oscli: EQU 10h + 00000011 B 57 mos_copy: EQU 11h + 00000012 B 58 mos_getrtc: EQU 12h + 00000013 B 59 mos_setrtc: EQU 13h + 00000014 B 60 mos_setintvector: EQU 14h + 00000015 B 61 mos_uopen: EQU 15h + 00000016 B 62 mos_uclose: EQU 16h + 00000017 B 63 mos_ugetc: EQU 17h + 00000018 B 64 mos_uputc: EQU 18h + 00000019 B 65 mos_getfil: EQU 19h + 0000001A B 66 mos_fread: EQU 1Ah + 0000001B B 67 mos_fwrite: EQU 1Bh + 0000001C B 68 mos_flseek: EQU 1Ch + B 69 + B 70 ; FatFS file access functions + B 71 ; + 00000080 B 72 ffs_fopen: EQU 80h + 00000081 B 73 ffs_fclose: EQU 81h + 00000082 B 74 ffs_fread: EQU 82h + 00000083 B 75 ffs_fwrite: EQU 83h + 00000084 B 76 ffs_flseek: EQU 84h + 00000085 B 77 ffs_ftruncate: EQU 85h + 00000086 B 78 ffs_fsync: EQU 86h + 00000087 B 79 ffs_fforward: EQU 87h + 00000088 B 80 ffs_fexpand: EQU 88h + 00000089 B 81 ffs_fgets: EQU 89h + 0000008A B 82 ffs_fputc: EQU 8Ah + 0000008B B 83 ffs_fputs: EQU 8Bh + 0000008C B 84 ffs_fprintf: EQU 8Ch + 0000008D B 85 ffs_ftell: EQU 8Dh + 0000008E B 86 ffs_feof: EQU 8Eh + 0000008F B 87 ffs_fsize: EQU 8Fh + 00000090 B 88 ffs_ferror: EQU 90h + B 89 + B 90 ; FatFS directory access functions + B 91 ; + 00000091 B 92 ffs_dopen: EQU 91h + 00000092 B 93 ffs_dclose: EQU 92h + 00000093 B 94 ffs_dread: EQU 93h + 00000094 B 95 ffs_dfindfirst: EQU 94h + 00000095 B 96 ffs_dfindnext: EQU 95h + B 97 + B 98 ; FatFS file and directory management functions + B 99 ; + 00000096 B 100 ffs_stat: EQU 96h + 00000097 B 101 ffs_unlink: EQU 97h + 00000098 B 102 ffs_rename: EQU 98h + 00000099 B 103 ffs_chmod: EQU 99h + 0000009A B 104 ffs_utime: EQU 9Ah + 0000009B B 105 ffs_mkdir: EQU 9Bh + 0000009C B 106 ffs_chdir: EQU 9Ch + 0000009D B 107 ffs_chdrive: EQU 9Dh + 0000009E B 108 ffs_getcwd: EQU 9Eh + B 109 + B 110 ; FatFS volume management and system configurat + B 111 ; + 0000009F B 112 ffs_mount: EQU 9Fh + 000000A0 B 113 ffs_mkfs: EQU A0h + 000000A1 B 114 ffs_fdisk EQU A1h + 000000A2 B 115 ffs_getfree: EQU A2h + 000000A3 B 116 ffs_getlabel: EQU A3h + 000000A4 B 117 ffs_setlabel: EQU A4h + 000000A5 B 118 ffs_setcp: EQU A5h + B 119 + B 120 ; File access modes + B 121 ; + 00000001 B 122 fa_read: EQU 01h + 00000002 B 123 fa_write: EQU 02h + 00000000 B 124 fa_open_existing: EQU 00h + 00000004 B 125 fa_create_new: EQU 04h + 00000008 B 126 fa_create_always: EQU 08h + 00000010 B 127 fa_open_always: EQU 10h + 00000030 B 128 fa_open_append: EQU 30h + B 129 + B 130 ; System variable indexes for api_sysvars + B 131 ; Index into _sysvars in globals.asm + B 132 ; + 00000000 B 133 sysvar_time: EQU 00h ; 4: Clock timer in + 00000004 B 134 sysvar_vpd_pflags: EQU 04h ; 1: Flags to indic + 00000005 B 135 sysvar_keyascii: EQU 05h ; 1: ASCII keycode, + 00000006 B 136 sysvar_keymods: EQU 06h ; 1: Keycode modifi + 00000007 B 137 sysvar_cursorX: EQU 07h ; 1: Cursor X posit + 00000008 B 138 sysvar_cursorY: EQU 08h ; 1: Cursor Y posit + 00000009 B 139 sysvar_scrchar: EQU 09h ; 1: Character read + 0000000A B 140 sysvar_scrpixel: EQU 0Ah ; 3: Pixel data rea + 0000000D B 141 sysvar_audioChannel: EQU 0Dh ; 1: Audio chan + 0000000E B 142 sysvar_audioSuccess: EQU 0Eh ; 1: Audio chan + 0000000F B 143 sysvar_scrWidth: EQU 0Fh ; 2: Screen width i + 00000011 B 144 sysvar_scrHeight: EQU 11h ; 2: Screen height + 00000013 B 145 sysvar_scrCols: EQU 13h ; 1: Screen columns + 00000014 B 146 sysvar_scrRows: EQU 14h ; 1: Screen rows in + 00000015 B 147 sysvar_scrColours: EQU 15h ; 1: Number of colo + 00000016 B 148 sysvar_scrpixelIndex: EQU 16h ; 1: Index of p + 00000017 B 149 sysvar_vkeycode: EQU 17h ; 1: Virtual key co + 00000018 B 150 sysvar_vkeydown EQU 18h ; 1: Virtual key st + 00000019 B 151 sysvar_vkeycount: EQU 19h ; 1: Incremented ev + 0000001A B 152 sysvar_rtc: EQU 1Ah ; 8: Real time clock da + 00000022 B 153 sysvar_keydelay: EQU 22h ; 2: Keyboard repea + 00000024 B 154 sysvar_keyrate: EQU 24h ; 2: Keyboard repea + 00000026 B 155 sysvar_keyled: EQU 26h ; 1: Keyboard LED s + B 156 + B 157 ; Flags for the VPD protocol + B 158 ; + 00000001 B 159 vdp_pflag_cursor: EQU 00000001b + 00000002 B 160 vdp_pflag_scrchar: EQU 00000010b + 00000004 B 161 vdp_pflag_point: EQU 00000100b + 00000008 B 162 vdp_pflag_audio: EQU 00001000b + 00000010 B 163 vdp_pflag_mode: EQU 00010000b + 00000020 B 164 vdp_pflag_rtc: EQU 00100000b + B 165 + B 166 ; + B 167 ; FatFS structures + B 168 ; These mirror the structures contained in src_ + B 169 ; + B 170 ; Object ID and allocation information (FFOBJID + B 171 ; + B 172 FFOBJID .STRUCT +000000 B 173 fs: DS 3 ; Pointer to the hosting vo +000003 B 174 id: DS 2 ; Hosting volume mount ID +000005 B 175 attr: DS 1 ; Object attribute +000006 B 176 stat: DS 1 ; Object chain status ( +000007 B 177 sclust: DS 4 ; Object data start clu +00000B B 178 objsize: DS 4 ; Object size (valid wh + 0000000F B 179 FFOBJID_SIZE .ENDSTRUCT FFOBJID + B 180 ; + B 181 ; File object structure (FIL) + B 182 ; + B 183 FIL .STRUCT +000000 B 184 obj: .TAG FFOBJID ; Object identi +00000F B 185 flag: DS 1 ; File status flags +000010 B 186 err: DS 1 ; Abort flag (error cod +000011 B 187 fptr: DS 4 ; File read/write point +000015 B 188 clust: DS 4 ; Current cluster of fp +000019 B 189 sect: DS 4 ; Sector number appeari +00001D B 190 dir_sect: DS 4 ; Sector number contain +000021 B 191 dir_ptr: DS 3 ; Pointer to the direct + 00000024 B 192 FIL_SIZE .ENDSTRUCT FIL + B 193 ; + B 194 ; Directory object structure (DIR) + B 195 ; + B 196 DIR .STRUCT +000000 B 197 obj: .TAG FFOBJID ; Object identi +00000F B 198 dptr: DS 4 ; Current read/write of +000013 B 199 clust: DS 4 ; Current cluster +000017 B 200 sect: DS 4 ; Current sector (0:Rea +00001B B 201 dir: DS 3 ; Pointer to the direct +00001E B 202 fn: DS 12 ; SFN (in/out) {body[8],ext +00002A B 203 blk_ofs: DS 4 ; Offset of current ent + 0000002E B 204 DIR_SIZE .ENDSTRUCT DIR + B 205 ; + B 206 ; File information structure (FILINFO) + B 207 ; + B 208 FILINFO .STRUCT +000000 B 209 fsize: DS 4 ; File size +000004 B 210 fdate: DS 2 ; Modified date +000006 B 211 ftime: DS 2 ; Modified time +000008 B 212 fattrib: DS 1 ; File attribute +000009 B 213 altname: DS 13 ; Alternative file name +000016 B 214 fname: DS 256 ; Primary file name + 00000116 B 215 FILINFO_SIZE .ENDSTRUCT FILINFO + B 216 + B 217 ; + B 218 ; Macro for calling the API + B 219 ; Parameters: + B 220 ; - function: One of the function numbers liste + B 221 ; + B 222 MOSCALL: MACRO function + B 223 LD A, function + B 224 RST.LIS 08h + B 225 ENDMACRO + B 226 ; + A 25 + A 26 SEGMENT CODE + A 27 + A 28 XDEF _main + A 29 XREF Print_Hex24 + A 30 XREF Print_Hex16 + A 31 XREF Print_Hex8 + A 32 + A 33 ; Error: Invalid parameter + A 34 ; +000145 211300 A 35 _err_invalid_param: LD HL, 19 ; T +000148 C9 A 36 RET + A 37 + A 38 + A 39 ; ASCII + A 40 ; + 00000003 A 41 CtrlC: equ 03h + A 42 CR: equ 0Dh + A 43 LF: equ 0Ah + 0000001A A 44 CtrlZ: equ 1Ah + A 45 ; + 000B0000 A 46 BASE: equ 0b0000h + A 47 +000149 A 48 _main: +000149 79 A 49 ld a,c ;AGON - number of parameters +00014A 3D A 50 dec a +00014B CA 7C 02 A 51 jp z,okusage +00014E FE03 A 52 cp 3 ;too many parameters +000150 D2 82 02 A 53 jp nc,badusage + A 54 +000153 5BDD2703 A 55 LD.LIL HL,(IX+3) ; HLU: pointer +000157 0E01 A 56 ld c,fa_read ;open read-only + A 57 MOSCALL mos_fopen +00015D B7 A 58 or a +00015E 20 0E A 59 jr nz,open_ok +000160 210400 A 60 ld hl,4 ;file not found/could not find +000163 C9 A 61 ret ;exit + A 62 ; + A 63 ; + A 64 ; Close and exit routines + A 65 ; + A 66 +000164 A 67 close: + A 68 ;C: Filehandle, or 0 to close all open files + A 69 ;returns number of still open files - how about + A 70 +000164 0E00 A 71 ld c,0 + A 72 MOSCALL mos_fclose + A 73 +00016A A 74 exit: +00016A 210000 A 75 ld hl,0 ;for Agon - successful exit +00016D C9 A 76 ret + A 77 ; + A 78 ; +00016E A 79 open_ok: + A 80 +00016E 32 51 03 A 81 ld (in_handle),a ;store the file handle + A 82 MOSCALL mos_sysvars ;get the sysvars locati +000175 DD7E19 A 83 ld a,(IX+sysvar_vkeycount) ;fetch keycount +000178 32 BB 03 A 84 ld (keycount),a ;store to compare again +00017B 5B21F0FF FF A 85 ld.lil hl,0-16 +000180 5B22 52 03 0B A 86 ld.lil (counter+BASE),hl +000185 A 87 printlp: + A 88 + A 89 +000185 5B21 56 03 0B A 90 ld.lil hl,buffer+BASE +00018A 5B111000 00 A 91 ld.lil de,16 +00018F 3A 51 03 A 92 ld a,(in_handle) +000192 4F A 93 ld c,a + A 94 MOSCALL mos_fread +000197 7B A 95 ld a,e +000198 B7 A 96 or a +000199 CA 2E 02 A 97 jp z,donefile +00019C 47 A 98 ld b,a ;b will track length for next l +00019D 5B2A 52 03 0B A 99 ld.lil hl,(counter+BASE) +0001A2 5B111000 00 A 100 ld.lil de,16 +0001A7 5B19 A 101 add.lil hl,de +0001A9 5B22 52 03 0B A 102 ld.lil (counter+BASE),hl +0001AE C5 A 103 push bc +0001AF CD 29 03 A 104 call Print_Hex24 +0001B2 C1 A 105 pop bc +0001B3 A 106 hexloop: +0001B3 3E3A A 107 ld a,':' +0001B5 D7 A 108 rst 10h +0001B6 21 56 03 A 109 ld hl,buffer +0001B9 0E00 A 110 ld c,0 +0001BB A 111 hexlp1: +0001BB 79 A 112 ld a,c +0001BC E603 A 113 and 3 +0001BE 20 07 A 114 jr nz,$f +0001C0 3E20 A 115 ld a,' ' +0001C2 E5 A 116 push hl +0001C3 C5 A 117 push bc +0001C4 D7 A 118 rst 10h +0001C5 C1 A 119 pop bc +0001C6 E1 A 120 pop hl +0001C7 A 121 $$: +0001C7 7E A 122 ld a,(hl) + A 123 +0001C8 E5 A 124 push hl +0001C9 C5 A 125 push bc +0001CA CD 3E 03 A 126 call Print_Hex8 +0001CD C1 A 127 pop bc +0001CE E1 A 128 pop hl +0001CF 23 A 129 inc hl +0001D0 A 130 hexlp2: +0001D0 0C A 131 inc c +0001D1 79 A 132 ld a,c +0001D2 FE10 A 133 cp 16 +0001D4 CA E8 01 A 134 jp z,hexend +0001D7 B8 A 135 cp b +0001D8 38 E1 A 136 jr c,hexlp1 +0001DA 3E20 A 137 ld a,' ' +0001DC D7 A 138 rst 10h +0001DD D7 A 139 rst 10h +0001DE 79 A 140 ld a,c +0001DF E603 A 141 and 3 +0001E1 20 03 A 142 jr nz,$f +0001E3 3E20 A 143 ld a,' ' +0001E5 D7 A 144 rst 10h +0001E6 A 145 $$: +0001E6 18 E8 A 146 jr hexlp2 + A 147 +0001E8 A 148 hexend: +0001E8 3E20 A 149 ld a,' ' +0001EA D7 A 150 rst 10h + A 151 +0001EB A 152 asciiloop: +0001EB 3E7C A 153 ld a,'|' +0001ED D7 A 154 rst 10h +0001EE 21 56 03 A 155 ld hl,buffer +0001F1 0E00 A 156 ld c,0 +0001F3 A 157 asciilp1: +0001F3 7E A 158 ld a,(hl) +0001F4 CD 37 02 A 159 call unprintable +0001F7 A 160 asciilp2: +0001F7 E5 A 161 push hl +0001F8 C5 A 162 push bc +0001F9 D7 A 163 rst 10h +0001FA C1 A 164 pop bc +0001FB E1 A 165 pop hl +0001FC 23 A 166 inc hl +0001FD 0C A 167 inc c +0001FE 79 A 168 ld a,c +0001FF FE10 A 169 cp 16 +000201 CA 0B 02 A 170 jp z,asciiend +000204 B8 A 171 cp b +000205 38 EC A 172 jr c,asciilp1 +000207 3E20 A 173 ld a,' ' +000209 18 EC A 174 jr asciilp2 + A 175 +00020B A 176 asciiend: +00020B CD 41 02 A 177 call inline_print +00020E 7C0D0A00 A 178 db '|',CR,LF,0 +000212 C3 85 01 A 179 jp printlp + A 180 + A 181 + A 182 + A 183 +000215 A 184 printbuff: + A 185 ; push bc ;preserve length +000215 11 56 03 A 186 ld de,buffer +000218 A 187 $$: +000218 1A A 188 ld a,(de) +000219 D7 A 189 rst 10h +00021A 13 A 190 inc de +00021B 10 FB A 191 djnz $b + A 192 ; pop bc + A 193 ;now keep printing until unprintable again +00021D A 194 allgood_lp +00021D CD 4D 02 A 195 call getbyte +000220 CD 37 02 A 196 call unprintable +000223 28 03 A 197 jr z,endstring +000225 D7 A 198 rst 10h +000226 18 F5 A 199 jr allgood_lp +000228 A 200 endstring: +000228 CD 41 02 A 201 call inline_print +00022B 0D0A00 A 202 db CR,LF,0 ;newline at end - TEST + A 203 +00022E A 204 donefile: +00022E CD 41 02 A 205 call inline_print +000231 0D0A00 A 206 db CR,LF,0 +000234 C3 64 01 A 207 jp close + A 208 + A 209 + A 210 ; Entry: + A 211 ; A is a character to test + A 212 ; Exit: + A 213 ; unprintable character converted to a '.' +000237 A 214 unprintable: +000237 FE20 A 215 cp ' ' +000239 38 03 A 216 jr c,$f +00023B FE7F A 217 cp 127 +00023D D8 A 218 ret c ;always nz +00023E 3E2E A 219 $$: ld a,'.' ;xor a ;sets 0 flag +000240 C9 A 220 ret + A 221 ; + A 222 ; Prints string directly after the call + A 223 ; +000241 E1 A 224 inline_print: pop hl +000242 CD 48 02 A 225 call print_string +000245 E9 A 226 jp (hl) + A 227 ; + A 228 ; more efficient print string for strings > 1 c +000246 A 229 $$: +000246 D7 A 230 rst 10h ;Agon uses this to print the charac +000247 23 A 231 inc hl +000248 7E A 232 print_string: ld a,(hl) +000249 B7 A 233 or a +00024A 20 FA A 234 jr nz,$b +00024C C9 A 235 ret + A 236 ; + A 237 ; +00024D A 238 getbyte: +00024D CD 59 02 A 239 call ck_ctrlC +000250 3A 51 03 A 240 ld a,(in_handle) +000253 4F A 241 ld c,a + A 242 MOSCALL mos_fgetc ;carry flag on last byt +000258 C9 A 243 ret + A 244 + A 245 ; Check for ctrl-C. If so, clean stack and exit + A 246 ; +000259 A 247 ck_ctrlC: +000259 3E01 A 248 ld a,1 ; modified below by self modify +00025B 3D A 249 dec a +00025C E60F A 250 and 15 +00025E 32 5A 02 A 251 ld (ck_ctrlC+1),a ; update LD A instructi +000261 C0 A 252 ret nz ; check every 16 calls only + A 253 MOSCALL mos_sysvars ;get the sysvars locati +000266 5BDD7E19 A 254 ld.lil a,(IX+sysvar_vkeycount) ;check if a +00026A 21 BB 03 A 255 ld hl,keycount +00026D BE A 256 cp (hl) ;compare against keycount for c +00026E C8 A 257 ret z +00026F 77 A 258 ld (hl),a ;update keycount +000270 5BDD7E05 A 259 ld.lil a,(IX+sysvar_keyascii) ;fetch char +000274 FE03 A 260 cp 3 ;is it ctr-C +000276 C0 A 261 ret nz +000277 E1 A 262 pop hl ;clean up stack +000278 E1 A 263 pop hl +000279 C3 64 01 A 264 jp close + A 265 +00027C CD 88 02 A 266 okusage: call usage +00027F C3 6A 01 A 267 jp exit + A 268 +000282 CD 88 02 A 269 badusage: call usage +000285 C3 45 01 A 270 jp _err_invalid_param + A 271 ; + A 272 ; usage -- show syntax + A 273 ; +000288 CD 41 02 A 274 usage: call inline_print +00028B 0D0A6865 7864756D A 275 db CR,LF,'hexdump utility for Agon by Shaw +000293 70207574 696C6974 +00029B 7920666F 72204167 +0002A3 6F6E2062 79205368 +0002AB 61776E20 53696A6E +0002B3 73747261 2031312D +0002BB 4A756E2D 32303233 +0002C3 0D0A0D0A +0002C7 55736167 653A0D0A A 276 db 'Usage:',CR,LF +0002CF 20202068 65786475 A 277 db ' hexdump ',CR,LF,CR,LF +0002D7 6D70203C 66696C65 +0002DF 3E0D0A0D 0A +0002E4 53746F72 65206865 A 278 db 'Store hexdump.bin in /mos directory. M +0002EC 7864756D 702E6269 +0002F4 6E20696E 202F6D6F +0002FC 73206469 72656374 +000304 6F72792E 204D696E +00030C 696D756D 204D4F53 +000314 20766572 73696F6E +00031C 20312E30 332E0D0A +000324 0D0A00 +000327 C9 A 279 ret + A 280 + A 281 ; + A 282 ; data storage . . . + A 283 ; +000328 A 284 stringlength: +000328 04 A 285 db 4 ;default of 4 characters + A 286 ; uninitialized storage/BSS but can't use that + A 287 ; + A 288 ; RAM + A 289 ; + A 290 DEFINE LORAM, SPACE = ROM + A 291 ; ORDER __VECTORS, CODE, LORAM + A 292 SEGMENT LORAM + A 293 + A 294 ; SEGMENT BSS + A 295 ; SEGMENT CODE + A 296 +000351 A 297 in_handle: DS 1 ;Only needs 1 byte handle +000352 A 298 counter: DS 4 +000356 A 299 buffer: DS 100 ;Space to buffer incoming s +0003BA A 300 curbyte: DS 1 ;current byte in the buffer +0003BB A 301 keycount: DS 1 ;current key count + A 302 end + + +Errors: 0 +Warnings: 0 +Lines Assembled: 640 diff --git a/hexdump/Release/main.obj b/hexdump/Release/main.obj new file mode 100644 index 0000000000000000000000000000000000000000..b6c0a2e8b693e6b6badf02ec00c83c374e49b941 GIT binary patch literal 2631 zcmb_eT}&KR6uz@_ce(5qoCZy3lZIK1&=}dmLL(AOL_oy|YgjZUkdVc0%TRWg?1C+^ zX~XK1Pm}oMlMiO!eXG9EHj73~zy=?-FHPFXWhn_0!NeCa;5jpMhn)>AHEFWhx#zp* z=R4<~duATiCUUuCYH}u-J=fnop17PzTYs&y+01nEv$jS~5a5OUKfN${-gF-ksseq)qmd`=i8iu=SU`SJO!Q3^P64LpPI?ljZk z;f}7|wPw=n+i5}J&E2&Y(&F0)@WyZh;cSJo1vZ=K9rgM zQ-Iy(%D&9mx(#2bQbXBMQ^y{($XuzHxY85k%HZ#u-QrAT^$?L-5tVuZdm(GDF-&Y0 z(WUi}PAc5ml8D{IZ1o2>PH|@GPJ47watVZY4%h)##$HCB66|~#B3{=OAX>R8d(;&t z@3AoY@gL=<0<7{=vE%qr$4)AQLAKpbO_jxjEn)90Y=&O9EOP zNdVNy9*ecobNyMf0lKSrmlpr>hDT9^ugdTU?!S1AQ541&_idY5Bik0?{`Fd*Xj_={ zdR>qh_X0?2RWEQ>M1F63^idK4PKsM`?dSW&b8;_o2!WYnDQXS!v`Y*<)(UBGWA^ z4LD9{f?L?p|5(P3<%?C8C=1JH7#%0<(Xj%YB%JI@`2}lY;&ew>IQqniRbnE<9WbHR%WQY50$}MLSGd7px1~H!Uya^@2%1&LzN2vilJJ8evsc z!6SYdm^3x3zGc!&+6=Ji0SBh!y7&%t<8zrT=&BWLBa@m*)2aqc)N?6dn^P|Wl7%l1 z;GA8E06v7fS_-pMhhlN~|2zqPa#{wh+9Pcy?TFL`&BObYmkhihE2cz64qPv6gp7M3 z`*mBjfH$FyxC>1n?gHA&)^QhC^ukUQzF5w;?XE>hG+(nB2)*?B`JGP0qPuIIq?2r& z34N5+(sL8H}9`z3n z<7#lvCy&I2q`o~#9_byD`pdrJa!q`6BtFnLN{F=SlZ-!nq#P(N)4o{$03p8306>Af z#LF^(qu>!i89BaaW%->rXi1wC U5K78^aM<5F+KZ4MAU}EZAJ7PpzyJUM literal 0 HcmV?d00001 diff --git a/hexdump/Release/output.lst b/hexdump/Release/output.lst new file mode 100644 index 0000000..64fe229 --- /dev/null +++ b/hexdump/Release/output.lst @@ -0,0 +1,156 @@ +Zilog eZ80 Macro Assembler Version 4.3 (19073001) RELISTED11-Jun-23 21:44:53 page: 1 + + +PC Object I Line Source + A 1 ; + A 2 ; Title: Memory Dump - Output functions + A 3 ; Author: Dean Belfield + A 4 ; Created: 15/11/2022 + A 5 ; Last Updated: 15/11/2022 + A 6 ; + A 7 ; Modinfo: + A 8 + B 0 INCLUDE "equs.inc" + B 1 ; + B 2 ; Title: Memory Dump - Equs + B 3 ; Author: Dean Belfield + B 4 ; Created: 15/11/2022 + B 5 ; Last Updated: 15/11/2022 + B 6 ; + B 7 ; Modinfo: + B 8 + 0000FF00 B 9 RAM_Top: EQU 0FF00h + 00000000 B 10 Stack_Top: EQU 00000h ; Stack at top + B 11 + B 12 ; For GPIO + B 13 ; PA not available on eZ80L92 + B 14 ; + 00000096 B 15 PA_DR: EQU 96h + 00000097 B 16 PA_DDR: EQU 97h + 00000098 B 17 PA_ALT1: EQU 98h + 00000099 B 18 PA_ALT2: EQU 99h + 0000009A B 19 PB_DR: EQU 9Ah + 0000009B B 20 PB_DDR: EQU 9Bh + 0000009C B 21 PB_ALT1: EQU 9Ch + 0000009D B 22 PB_ALT2: EQU 9Dh + 0000009E B 23 PC_DR: EQU 9Eh + 0000009F B 24 PC_DDR: EQU 9Fh + 000000A0 B 25 PC_ALT1: EQU A0h + 000000A1 B 26 PC_ALT2: EQU A1h + 000000A2 B 27 PD_DR: EQU A2h + 000000A3 B 28 PD_DDR: EQU A3h + 000000A4 B 29 PD_ALT1: EQU A4h + 000000A5 B 30 PD_ALT2: EQU A5h + B 31 + 00000000 B 32 GPIOMODE_OUT: EQU 0 ; Output + 00000001 B 33 GPIOMODE_IN: EQU 1 ; Input + 00000002 B 34 GPIOMODE_DIO: EQU 2 ; Open Drain IO + 00000003 B 35 GPIOMODE_SIO: EQU 3 ; Open Source I + 00000004 B 36 GPIOMODE_INTD: EQU 4 ; Interrupt, Du + 00000005 B 37 GPIOMODE_ALTF: EQU 5; ; Alt Function + 00000006 B 38 GPIOMODE_INTAL: EQU 6 ; Interrupt, Ac + 00000007 B 39 GPIOMODE_INTAH: EQU 7 ; Interrupt, Ac + 00000008 B 40 GPIOMODE_INTFE: EQU 8 ; Interrupt, Fa + 00000009 B 41 GPIOMODE_INTRE: EQU 9 ; Interrupt, Ri + B 42 + B 43 ; For serial.asm + B 44 ; + 016E3600 B 45 BASE_CLOCK EQU 24000000 ; It's actually + B 46 + 00000003 B 47 BAUD_500000 EQU BASE_CLOCK / (16 * 500000) + 00000006 B 48 BAUD_250000 EQU BASE_CLOCK / (16 * 250000) + 0000000C B 49 BAUD_125000 EQU BASE_CLOCK / (16 * 125000) + 0000004E B 50 BAUD_19200 EQU BASE_CLOCK / (16 * 19200) + B 51 + B 52 ; For interrupts.asm + B 53 ; + B 54 + B 55 ;UARTs + B 56 ; + 00000018 B 57 UART0_IVECT EQU 18h + 0000001A B 58 UART1_IVECT EQU 1Ah + B 59 + B 60 ;Ports + B 61 ; + 00000030 B 62 PB0_IVECT EQU 30h ; AGON ITRP Int + 00000032 B 63 PB1_IVECT EQU 32h ; AGON VBLANK Inter + 00000034 B 64 PB2_IVECT EQU 34h + 00000036 B 65 PB3_IVECT EQU 36h + 00000038 B 66 PB4_IVECT EQU 38h + 0000003A B 67 PB5_IVECT EQU 3Ah + 0000003C B 68 PB6_IVECT EQU 3Ch + 0000003E B 69 PB7_IVECT EQU 3Eh + B 70 + 00000040 B 71 PC0_IVECT EQU 40h + 00000042 B 72 PC1_IVECT EQU 42h + 00000044 B 73 PC2_IVECT EQU 44h + 00000046 B 74 PC3_IVECT EQU 46h + 00000048 B 75 PC4_IVECT EQU 48h + 0000004A B 76 PC5_IVECT EQU 4Ah + 0000004C B 77 PC6_IVECT EQU 4Ch + 0000004E B 78 PC7_IVECT EQU 4Eh + B 79 + 00000050 B 80 PD0_IVECT EQU 50h + 00000052 B 81 PD1_IVECT EQU 52h + 00000054 B 82 PD2_IVECT EQU 54h + 00000056 B 83 PD3_IVECT EQU 56h + 00000058 B 84 PD4_IVECT EQU 58h + 0000005A B 85 PD5_IVECT EQU 5Ah + 0000005C B 86 PD6_IVECT EQU 5Ch + 0000005E B 87 PD7_IVECT EQU 5Eh + B 88 + B 89 ; Originally in main.asm + B 90 ; + 0000000D B 91 CR: EQU 0DH + 0000000A B 92 LF: EQU 0AH + 0000001B B 93 ESC: EQU 1BH + A 10 + A 11 .ASSUME ADL = 0 + A 12 + A 13 SEGMENT CODE + A 14 + A 15 XDEF Print_Hex24 + A 16 XDEF Print_Hex16 + A 17 XDEF Print_Hex8 + A 18 + A 19 + A 20 ; Print a 24-bit HEX number + A 21 ; HLU: Number to print + A 22 ; +000329 5BE5 A 23 Print_Hex24: PUSH.LIL HL +00032B 5B210200 00 A 24 LD.LIL HL, 2 +000330 5B39 A 25 ADD.LIL HL, SP +000332 5B7E A 26 LD.LIL A, (HL) +000334 5BE1 A 27 POP.LIL HL + A 28 +000336 CD 3E 03 A 29 CALL Print_Hex8 + A 30 + A 31 ; Print a 16-bit HEX number + A 32 ; HL: Number to print + A 33 ; +000339 7C A 34 Print_Hex16: LD A,H +00033A CD 3E 03 A 35 CALL Print_Hex8 +00033D 7D A 36 LD A,L + A 37 + A 38 ; Print an 8-bit HEX number + A 39 ; A: Number to print + A 40 ; +00033E 4F A 41 Print_Hex8: LD C,A +00033F 1F A 42 RRA +000340 1F A 43 RRA +000341 1F A 44 RRA +000342 1F A 45 RRA +000343 CD 47 03 A 46 CALL $F +000346 79 A 47 LD A,C +000347 E60F A 48 $$: AND 0Fh +000349 C690 A 49 ADD A,90h +00034B 27 A 50 DAA +00034C CE40 A 51 ADC A,40h +00034E 27 A 52 DAA +00034F D7 A 53 RST 10h +000350 C9 A 54 RET + + +Errors: 0 +Warnings: 0 +Lines Assembled: 148 diff --git a/hexdump/Release/output.obj b/hexdump/Release/output.obj new file mode 100644 index 0000000000000000000000000000000000000000..5bb6482e2c67bb283d55a995af6d82daf88a3c2a GIT binary patch literal 601 zcmaix&ubGw6vyA}%uc5E;DYq3?IrPG#jdHeo=lT~IV3CDMG6gsSQl+EKgbWLph8Rk zfW3R}-Kz-pkRa@#d(gvP?K0W);30d?LEl8{kCQMn-+7d(iI;`nMas<~Kplq7aS&;4lga zD%pxcP3eayq)K;IHg z(Phb((ul80(i`aW)fr}3uAu479Vx@ zTK)P%_rT01K7(ud$Y@t?iVs9xN5N){>3 zm|m)=TWO}zs#PZW8KKo&nG|AeI7-=0)h^~8oW?{W(H9M3J{+;URVd;BCL9sJ8B;_K w)>DWgq7akeXrW$zjHy=DR-7Ow5VPTkZrMo4gdt%N>zG`~IXQ)NL^_=R018{>7ytkO literal 0 HcmV?d00001 diff --git a/hexdump/eZ80F92_AGON_Flash.ztgt b/hexdump/eZ80F92_AGON_Flash.ztgt new file mode 100644 index 0000000..47720be --- /dev/null +++ b/hexdump/eZ80F92_AGON_Flash.ztgt @@ -0,0 +1,62 @@ + + + + Oscillator + 18432000 + + + 000000 + C0000 + FFFF + true + + + + 0 + false + 40000 + BFFFF + + 1 + false + true + + + + + 1 + 8 + 2 + 9 + + + 02 + 28 + C0 + C7 + + + 81 + 28 + 80 + BF + + + 02 + 00 + 00 + 00 + + + + 0 + ff + true + true + + 1 + + eZ80F92 + 1.0.1 + 1.00 + diff --git a/hexdump/equs.inc b/hexdump/equs.inc new file mode 100644 index 0000000..f1331eb --- /dev/null +++ b/hexdump/equs.inc @@ -0,0 +1,93 @@ +; +; Title: Memory Dump - Equs +; Author: Dean Belfield +; Created: 15/11/2022 +; Last Updated: 15/11/2022 +; +; Modinfo: + +RAM_Top: EQU 0FF00h +Stack_Top: EQU 00000h ; Stack at top + +; For GPIO +; PA not available on eZ80L92 +; +PA_DR: EQU 96h +PA_DDR: EQU 97h +PA_ALT1: EQU 98h +PA_ALT2: EQU 99h +PB_DR: EQU 9Ah +PB_DDR: EQU 9Bh +PB_ALT1: EQU 9Ch +PB_ALT2: EQU 9Dh +PC_DR: EQU 9Eh +PC_DDR: EQU 9Fh +PC_ALT1: EQU A0h +PC_ALT2: EQU A1h +PD_DR: EQU A2h +PD_DDR: EQU A3h +PD_ALT1: EQU A4h +PD_ALT2: EQU A5h + +GPIOMODE_OUT: EQU 0 ; Output +GPIOMODE_IN: EQU 1 ; Input +GPIOMODE_DIO: EQU 2 ; Open Drain IO +GPIOMODE_SIO: EQU 3 ; Open Source IO +GPIOMODE_INTD: EQU 4 ; Interrupt, Dual Edge +GPIOMODE_ALTF: EQU 5; ; Alt Function +GPIOMODE_INTAL: EQU 6 ; Interrupt, Active Low +GPIOMODE_INTAH: EQU 7 ; Interrupt, Active High +GPIOMODE_INTFE: EQU 8 ; Interrupt, Falling Edge +GPIOMODE_INTRE: EQU 9 ; Interrupt, Rising Edge + +; For serial.asm +; +BASE_CLOCK EQU 24000000 ; It's actually 48000000 in the Project Settings + +BAUD_500000 EQU BASE_CLOCK / (16 * 500000) +BAUD_250000 EQU BASE_CLOCK / (16 * 250000) +BAUD_125000 EQU BASE_CLOCK / (16 * 125000) +BAUD_19200 EQU BASE_CLOCK / (16 * 19200) + +; For interrupts.asm +; + +;UARTs +; +UART0_IVECT EQU 18h +UART1_IVECT EQU 1Ah + +;Ports +; +PB0_IVECT EQU 30h ; AGON ITRP Interrupt (Pin 28/IO17 of the ESP32) +PB1_IVECT EQU 32h ; AGON VBLANK Interrupt (Pin 23/IO15 of the ESP32) +PB2_IVECT EQU 34h +PB3_IVECT EQU 36h +PB4_IVECT EQU 38h +PB5_IVECT EQU 3Ah +PB6_IVECT EQU 3Ch +PB7_IVECT EQU 3Eh + +PC0_IVECT EQU 40h +PC1_IVECT EQU 42h +PC2_IVECT EQU 44h +PC3_IVECT EQU 46h +PC4_IVECT EQU 48h +PC5_IVECT EQU 4Ah +PC6_IVECT EQU 4Ch +PC7_IVECT EQU 4Eh + +PD0_IVECT EQU 50h +PD1_IVECT EQU 52h +PD2_IVECT EQU 54h +PD3_IVECT EQU 56h +PD4_IVECT EQU 58h +PD5_IVECT EQU 5Ah +PD6_IVECT EQU 5Ch +PD7_IVECT EQU 5Eh + +; Originally in main.asm +; +CR: EQU 0DH +LF: EQU 0AH +ESC: EQU 1BH diff --git a/hexdump/hexdump.wsp b/hexdump/hexdump.wsp new file mode 100644 index 0000000..0e948d7 --- /dev/null +++ b/hexdump/hexdump.wsp @@ -0,0 +1,44 @@ +[WorkState_v1_2] +ptn_Child1=Frames + +[WorkState_v1_2.Frames] +ptn_Child1=ChildFrames + +[WorkState_v1_2.Frames.ChildFrames] +ptn_Child1=Document-0 +ptn_Child2=Document-1 +ptn_Child3=Document-2 + +[WorkState_v1_2.Frames.ChildFrames.Document-0] +ptn_Child1=ViewFrame-0 + +[WorkState_v1_2.Frames.ChildFrames.Document-0.ViewFrame-0] +DocPathName=.\mos_api.inc +DocTemplateIndex=0 +DocumentString=IDE.Document +IsActiveChildFrame=False +IsFrameVisible=True +WindowPlacement=MCAAAAAAAAAAAAAABAAAAAAAPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPIGAAAAAAIGAAAAAAHHDAAAAAGJBAAAAA + +[WorkState_v1_2.Frames.ChildFrames.Document-1] +ptn_Child1=ViewFrame-0 + +[WorkState_v1_2.Frames.ChildFrames.Document-1.ViewFrame-0] +DocPathName=.\init.asm +DocTemplateIndex=0 +DocumentString=IDE.Document +IsActiveChildFrame=False +IsFrameVisible=True +WindowPlacement=MCAAAAAAAAAAAAAABAAAAAAAPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPCIAAAAAACIAAAAAABJDAAAAAALBAAAAA + +[WorkState_v1_2.Frames.ChildFrames.Document-2] +ptn_Child1=ViewFrame-0 + +[WorkState_v1_2.Frames.ChildFrames.Document-2.ViewFrame-0] +DocPathName=.\main.asm +DocTemplateIndex=0 +DocumentString=IDE.Document +IsActiveChildFrame=True +IsFrameVisible=True +WindowPlacement=MCAAAAAAAAAAAAAABAAAAAAAPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPAAAAAAAAAAAAAAAAPADAAAAAOCBAAAAA + diff --git a/hexdump/hexdump.zdsproj b/hexdump/hexdump.zdsproj new file mode 100644 index 0000000..a326b09 --- /dev/null +++ b/hexdump/hexdump.zdsproj @@ -0,0 +1,217 @@ + +eZ80F92 + + + +.\init.asm +.\main.asm +.\output.asm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 + +

262207
+ +1 + + + + \ No newline at end of file diff --git a/hexdump/init.asm b/hexdump/init.asm new file mode 100644 index 0000000..18e8270 --- /dev/null +++ b/hexdump/init.asm @@ -0,0 +1,198 @@ +; +; Title: Memory Dump - Initialisation Code +; Author: Dean Belfield +; Created: 15/11/2022 +; Last Updated: 23/12/2022 +; +; Modinfo: +; 23/12/2022: Added parameter parsing code + + SEGMENT __VECTORS + + XREF _main + + .ASSUME ADL = 0 + + INCLUDE "equs.inc" + +argv_ptrs_max: EQU 16 ; Maximum number of arguments allowed in argv + +; +; Start in mixed mode. Assumes MBASE is set to correct segment +; + JP _start ; Jump to start + DS 5 + +RST_08: RST.LIS 08h ; API call + RET + DS 5 + +RST_10: RST.LIS 10h ; Output + RET + DS 5 + +RST_18: DS 8 +RST_20: DS 8 +RST_28: DS 8 +RST_30: DS 8 +; +; The NMI interrupt vector (not currently used by AGON) +; +RST_38: EI + RETI +; +; The header stuff is from byte 64 onwards +; + ALIGN 64 + + DB "MOS" ; Flag for MOS - to confirm this is a valid MOS command + DB 00h ; MOS header version 0 + DB 00h ; Flag for run mode (0: Z80, 1: ADL) + +_exec_name: DB "HEXDUMP.BIN", 0 ; The executable name, only used in argv + +; +; And the code follows on immediately after the header +; +_start: PUSH.LIL IY ; Preserve IY + + LD IY, 0 ; Preserve SPS + ADD IY, SP + PUSH.LIL IY + LD SP, 8000h ; And set to 8000h, top of the MOS command area + + PUSH AF ; Preserve the rest of the registers + PUSH.LIL BC + PUSH.LIL DE + PUSH.LIL IX + + LD A, MB ; Segment base + LD IX, argv_ptrs ; The argv array pointer address + CALL _set_aix24 ; Convert to a 24-bit address + PUSH.LIL IX + CALL _parse_params ; Parse the parameters + POP.LIL IX ; IX: argv + LD B, 0 ; C: argc + CALL _main ; Start user code + + POP.LIL IX ; Restore the registers + POP.LIL DE + POP.LIL BC + POP AF + + POP.LIL IY ; Get the preserved SPS + LD SP, IY ; Restore the SP + + POP.LIL IY ; Restore IY + RET.L ; Return to MOS + +; Parse the parameter string into a C array +; Parameters +; - A: Segment base +; - HLU: Address of parameter string +; - IXU: Address for array pointer storage +; Returns: +; - C: Number of parameters parsed +; +_parse_params: LD BC, _exec_name ; Get the address of the app name in this segment + CALL _set_abc24 ; Convert it to a 24-bit address based upon segment base + LD.LIL (IX+0), BC ; ARGV[0] = the executable name + INC.LIL IX + INC.LIL IX + INC.LIL IX + CALL _skip_spaces ; Skip HL past any leading spaces +; + LD BC, 1 ; C: ARGC = 1 - also clears out top 16 bits of BCU + LD B, argv_ptrs_max - 1 ; B: Maximum number of argv_ptrs +; +_parse_params_1: PUSH BC ; Stack ARGC + PUSH.LIL HL ; Stack start address of token + CALL _get_token ; Get the next token + LD A, C ; A: Length of the token in characters + POP.LIL DE ; Start address of token (was in HL) + POP BC ; ARGC + OR A ; Check for A=0 (no token found) OR at end of string + RET Z +; + LD.LIL (IX+0), DE ; Store the pointer to the token + PUSH.LIL HL ; DE=HL + POP.LIL DE + CALL _skip_spaces ; And skip HL past any spaces onto the next character + XOR A + LD.LIL (DE), A ; Zero-terminate the token + INC.LIL IX + INC.LIL IX + INC.LIL IX ; Advance to next pointer position + INC C ; Increment ARGC + LD A, C ; Check for C >= A + CP B + JR C, _parse_params_1 ; And loop + RET + +; Get the next token +; Parameters: +; - HL: Address of parameter string +; Returns: +; - HL: Address of first character after token +; - C: Length of token (in characters) +; +_get_token: LD C, 0 ; Initialise length +$$: LD.LIL A, (HL) ; Get the character from the parameter string + OR A ; Exit if 0 (end of parameter string in MOS) + RET Z + CP 13 ; Exit if CR (end of parameter string in BBC BASIC) + RET Z + CP ' ' ; Exit if space (end of token) + RET Z + INC.LIL HL ; Advance to next character + INC C ; Increment length + JR $B + +; Skip spaces in the parameter string +; Parameters: +; - HL: Address of parameter string +; Returns: +; - HL: Address of next none-space character +; F: Z if at end of string, otherwise NZ if there are more tokens to be parsed +; +_skip_spaces: LD.LIL A, (HL) ; Get the character from the parameter string + CP ' ' ; Exit if not space + RET NZ + INC.LIL HL ; Advance to next character + JR _skip_spaces ; Increment length + +; Set the MSB of BC (U) to A +; Parameters: +; - BC: 16-bit address +; - A: Value to stick in U of BC +; Returns: +; - BCU +; +_set_abc24: PUSH.LIL HL ; Preserve HL + PUSH.LIL BC ; Stick BC onto SPL + LD.LIL HL, 2 ; HL: SP+2 + ADD.LIL HL, SP + LD.LIL (HL), A ; Store A in it + POP.LIL BC ; Fetch ammended BC + POP.LIL HL ; Restore HL + RET + +; Set the MSB of BC (U) to A +; Parameters: +; - IX: 16-bit address +; - A: Value to stick in U of BC +; Returns: +; - IXU +; +_set_aix24: PUSH.LIL IX ; Stick IX onto SPL + LD.LIL IX, 2 ; IX: SP+2 + ADD.LIL IX, SP + LD.LIL (IX), A ; Store A in it + POP.LIL IX ; Fetch ammended IX + RET + +; Storage for the argv array pointers +; +argv_ptrs: BLKP argv_ptrs_max, 0 ; Storage for the argv array pointers + + END \ No newline at end of file diff --git a/hexdump/main.asm b/hexdump/main.asm new file mode 100644 index 0000000..1fb56a5 --- /dev/null +++ b/hexdump/main.asm @@ -0,0 +1,302 @@ +; HEXDUMP utility +; +; +; Written Agon native by Shawn Sijnstra +; +; Notable changes for reference: +; required colons on all labels +; labels are case sensitive +; code is a reserved word and can't be used as a label +; numeric evaluations are done differently - check results carefully +; reserved word INCLUDE needs to be in upper case, and file needs to have inverted commas +; assembly source MUST be .asm, can't use e.g. .zsm +; supports defb as a synonym for db, but NOT defw. Must use dw. defs also missing - use ds. +; labels can't start with @ +; +; DESIGN OF WIDTH: +; 6 chars for current byte +; dddddd: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX |................| + + + .ASSUME ADL = 0 + + INCLUDE "equs.inc" + INCLUDE "mos_api.inc" ; In MOS/src + + SEGMENT CODE + + XDEF _main + XREF Print_Hex24 + XREF Print_Hex16 + XREF Print_Hex8 + +; Error: Invalid parameter +; +_err_invalid_param: LD HL, 19 ; The return code: Invalid parameters + RET + + +; ASCII +; +CtrlC: equ 03h +CR: equ 0Dh +LF: equ 0Ah +CtrlZ: equ 1Ah +; +BASE: equ 0b0000h + +_main: + ld a,c ;AGON - number of parameters + dec a + jp z,okusage + cp 3 ;too many parameters + jp nc,badusage + + LD.LIL HL,(IX+3) ; HLU: pointer to first argument + ld c,fa_read ;open read-only + MOSCALL mos_fopen + or a + jr nz,open_ok + ld hl,4 ;file not found/could not find file - error opening file [not necessarily correct error though] + ret ;exit +; +; +; Close and exit routines +; + +close: +;C: Filehandle, or 0 to close all open files +;returns number of still open files - how about we just always close all? + + ld c,0 + MOSCALL mos_fclose + +exit: + ld hl,0 ;for Agon - successful exit + ret +; +; +open_ok: + + ld (in_handle),a ;store the file handle number + MOSCALL mos_sysvars ;get the sysvars location - consider saving IX for speed + ld a,(IX+sysvar_vkeycount) ;fetch keycount + ld (keycount),a ;store to compare against + ld.lil hl,0-16 + ld.lil (counter+BASE),hl +printlp: + + + ld.lil hl,buffer+BASE + ld.lil de,16 + ld a,(in_handle) + ld c,a + MOSCALL mos_fread + ld a,e + or a + jp z,donefile + ld b,a ;b will track length for next loop + ld.lil hl,(counter+BASE) + ld.lil de,16 + add.lil hl,de + ld.lil (counter+BASE),hl + push bc + call Print_Hex24 + pop bc +hexloop: + ld a,':' + rst 10h + ld hl,buffer + ld c,0 +hexlp1: + ld a,c + and 3 + jr nz,$f + ld a,' ' + push hl + push bc + rst 10h + pop bc + pop hl +$$: + ld a,(hl) + + push hl + push bc + call Print_Hex8 + pop bc + pop hl + inc hl +hexlp2: + inc c + ld a,c + cp 16 + jp z,hexend + cp b + jr c,hexlp1 + ld a,' ' + rst 10h + rst 10h + ld a,c + and 3 + jr nz,$f + ld a,' ' + rst 10h +$$: + jr hexlp2 + +hexend: + ld a,' ' + rst 10h + +asciiloop: + ld a,'|' + rst 10h + ld hl,buffer + ld c,0 +asciilp1: + ld a,(hl) + call unprintable +asciilp2: + push hl + push bc + rst 10h + pop bc + pop hl + inc hl + inc c + ld a,c + cp 16 + jp z,asciiend + cp b + jr c,asciilp1 + ld a,' ' + jr asciilp2 + +asciiend: + call inline_print + db '|',CR,LF,0 + jp printlp + + + + +printbuff: +; push bc ;preserve length + ld de,buffer +$$: + ld a,(de) + rst 10h + inc de + djnz $b +; pop bc +;now keep printing until unprintable again +allgood_lp + call getbyte + call unprintable + jr z,endstring + rst 10h + jr allgood_lp +endstring: + call inline_print + db CR,LF,0 ;newline at end - TEST + +donefile: + call inline_print + db CR,LF,0 + jp close + + +; Entry: +; A is a character to test +; Exit: +; unprintable character converted to a '.' +unprintable: + cp ' ' + jr c,$f + cp 127 + ret c ;always nz +$$: ld a,'.' ;xor a ;sets 0 flag + ret +; +; Prints string directly after the call +; +inline_print: pop hl + call print_string + jp (hl) +; +; more efficient print string for strings > 1 character +$$: + rst 10h ;Agon uses this to print the character in A. Preserves HL. + inc hl +print_string: ld a,(hl) + or a + jr nz,$b + ret +; +; +getbyte: + call ck_ctrlC + ld a,(in_handle) + ld c,a + MOSCALL mos_fgetc ;carry flag on last byte not yet implemented. + ret + +; Check for ctrl-C. If so, clean stack and exit. +; +ck_ctrlC: + ld a,1 ; modified below by self modifying code + dec a + and 15 + ld (ck_ctrlC+1),a ; update LD A instruction above + ret nz ; check every 16 calls only + MOSCALL mos_sysvars ;get the sysvars location - consider saving IX for speed + ld.lil a,(IX+sysvar_vkeycount) ;check if any key has been pressed + ld hl,keycount + cp (hl) ;compare against keycount for change + ret z + ld (hl),a ;update keycount + ld.lil a,(IX+sysvar_keyascii) ;fetch character in queue + cp 3 ;is it ctr-C + ret nz + pop hl ;clean up stack + pop hl + jp close + +okusage: call usage + jp exit + +badusage: call usage + jp _err_invalid_param +; +; usage -- show syntax +; +usage: call inline_print + db CR,LF,'hexdump utility for Agon by Shawn Sijnstra 11-Jun-2023',CR,LF,CR,LF + db 'Usage:',CR,LF + db ' hexdump ',CR,LF,CR,LF + db 'Store hexdump.bin in /mos directory. Minimum MOS version 1.03.',CR,LF,CR,LF,0 + ret + +; +; data storage . . . +; +stringlength: + db 4 ;default of 4 characters +; uninitialized storage/BSS but can't use that terminology because it's all in ROM space +; +; RAM +; + DEFINE LORAM, SPACE = ROM +; ORDER __VECTORS, CODE, LORAM + SEGMENT LORAM + +; SEGMENT BSS +; SEGMENT CODE + +in_handle: DS 1 ;Only needs 1 byte handle +counter: DS 4 +buffer: DS 100 ;Space to buffer incoming strings +curbyte: DS 1 ;current byte in the buffer +keycount: DS 1 ;current key count + end diff --git a/hexdump/mos_api.inc b/hexdump/mos_api.inc new file mode 100644 index 0000000..3c18ea0 --- /dev/null +++ b/hexdump/mos_api.inc @@ -0,0 +1,226 @@ +; +; Title: AGON MOS - API for user projects +; Author: Dean Belfield +; Created: 03/08/2022 +; Last Updated: 15/04/2023 +; +; Modinfo: +; 05/08/2022: Added mos_feof +; 09/08/2022: Added system variables: cursorX, cursorY +; 18/08/2022: Added system variables: scrchar, scrpixel, audioChannel, audioSuccess, vpd_pflags +; 05/09/2022: Added mos_ren, vdp_pflag_mode +; 24/09/2022: Added mos_getError, mos_mkdir +; 13/10/2022: Added mos_oscli +; 23/02/2023: Added more sysvars, fixed typo in sysvar_audioSuccess, offsets for sysvar_scrCols, sysvar_scrRows +; 04/03/2023: Added sysvar_scrpixelIndex +; 08/03/2023: Renamed sysvar_keycode to sysvar_keyascii, added sysvar_vkeycode +; 15/03/2023: Added mos_copy, mos_getrtc, mos_setrtc, rtc, vdp_pflag_rtc +; 21/03/2023: Added mos_setintvector, sysvars for keyboard status, vdu codes for vdp +; 22/03/2023: The VDP commands are now indexed from 0x80 +; 29/03/2023: Added mos_uopen, mos_uclose, mos_ugetc, mos_uputc +; 13/04/2023: Added FatFS file structures (FFOBJID, FIL, DIR, FILINFO) +; 15/04/2023: Added mos_getfil, mos_fread, mos_fwrite and mos_flseek + +; VDP control (VDU 23, 0, n) +; +vdp_gp: EQU 80h +vdp_keycode: EQU 81h +vdp_cursor: EQU 82h +vdp_scrchar: EQU 83h +vdp_scrpixel: EQU 84h +vdp_audio: EQU 85h +vdp_mode: EQU 86h +vdp_rtc: EQU 87h +vdp_keystate: EQU 88h +vdp_logicalcoords: EQU C0h +vdp_terminalmode: EQU FFh + +; MOS high level functions +; +mos_getkey: EQU 00h +mos_load: EQU 01h +mos_save: EQU 02h +mos_cd: EQU 03h +mos_dir: EQU 04h +mos_del: EQU 05h +mos_ren: EQU 06h +mos_mkdir: EQU 07h +mos_sysvars: EQU 08h +mos_editline: EQU 09h +mos_fopen: EQU 0Ah +mos_fclose: EQU 0Bh +mos_fgetc: EQU 0Ch +mos_fputc: EQU 0Dh +mos_feof: EQU 0Eh +mos_getError: EQU 0Fh +mos_oscli: EQU 10h +mos_copy: EQU 11h +mos_getrtc: EQU 12h +mos_setrtc: EQU 13h +mos_setintvector: EQU 14h +mos_uopen: EQU 15h +mos_uclose: EQU 16h +mos_ugetc: EQU 17h +mos_uputc: EQU 18h +mos_getfil: EQU 19h +mos_fread: EQU 1Ah +mos_fwrite: EQU 1Bh +mos_flseek: EQU 1Ch + +; FatFS file access functions +; +ffs_fopen: EQU 80h +ffs_fclose: EQU 81h +ffs_fread: EQU 82h +ffs_fwrite: EQU 83h +ffs_flseek: EQU 84h +ffs_ftruncate: EQU 85h +ffs_fsync: EQU 86h +ffs_fforward: EQU 87h +ffs_fexpand: EQU 88h +ffs_fgets: EQU 89h +ffs_fputc: EQU 8Ah +ffs_fputs: EQU 8Bh +ffs_fprintf: EQU 8Ch +ffs_ftell: EQU 8Dh +ffs_feof: EQU 8Eh +ffs_fsize: EQU 8Fh +ffs_ferror: EQU 90h + +; FatFS directory access functions +; +ffs_dopen: EQU 91h +ffs_dclose: EQU 92h +ffs_dread: EQU 93h +ffs_dfindfirst: EQU 94h +ffs_dfindnext: EQU 95h + +; FatFS file and directory management functions +; +ffs_stat: EQU 96h +ffs_unlink: EQU 97h +ffs_rename: EQU 98h +ffs_chmod: EQU 99h +ffs_utime: EQU 9Ah +ffs_mkdir: EQU 9Bh +ffs_chdir: EQU 9Ch +ffs_chdrive: EQU 9Dh +ffs_getcwd: EQU 9Eh + +; FatFS volume management and system configuration functions +; +ffs_mount: EQU 9Fh +ffs_mkfs: EQU A0h +ffs_fdisk EQU A1h +ffs_getfree: EQU A2h +ffs_getlabel: EQU A3h +ffs_setlabel: EQU A4h +ffs_setcp: EQU A5h + +; File access modes +; +fa_read: EQU 01h +fa_write: EQU 02h +fa_open_existing: EQU 00h +fa_create_new: EQU 04h +fa_create_always: EQU 08h +fa_open_always: EQU 10h +fa_open_append: EQU 30h + +; System variable indexes for api_sysvars +; Index into _sysvars in globals.asm +; +sysvar_time: EQU 00h ; 4: Clock timer in centiseconds (incremented by 2 every VBLANK) +sysvar_vpd_pflags: EQU 04h ; 1: Flags to indicate completion of VDP commands +sysvar_keyascii: EQU 05h ; 1: ASCII keycode, or 0 if no key is pressed +sysvar_keymods: EQU 06h ; 1: Keycode modifiers +sysvar_cursorX: EQU 07h ; 1: Cursor X position +sysvar_cursorY: EQU 08h ; 1: Cursor Y position +sysvar_scrchar: EQU 09h ; 1: Character read from screen +sysvar_scrpixel: EQU 0Ah ; 3: Pixel data read from screen (R,B,G) +sysvar_audioChannel: EQU 0Dh ; 1: Audio channel +sysvar_audioSuccess: EQU 0Eh ; 1: Audio channel note queued (0 = no, 1 = yes) +sysvar_scrWidth: EQU 0Fh ; 2: Screen width in pixels +sysvar_scrHeight: EQU 11h ; 2: Screen height in pixels +sysvar_scrCols: EQU 13h ; 1: Screen columns in characters +sysvar_scrRows: EQU 14h ; 1: Screen rows in characters +sysvar_scrColours: EQU 15h ; 1: Number of colours displayed +sysvar_scrpixelIndex: EQU 16h ; 1: Index of pixel data read from screen +sysvar_vkeycode: EQU 17h ; 1: Virtual key code from FabGL +sysvar_vkeydown EQU 18h ; 1: Virtual key state from FabGL (0=up, 1=down) +sysvar_vkeycount: EQU 19h ; 1: Incremented every time a key packet is received +sysvar_rtc: EQU 1Ah ; 8: Real time clock data +sysvar_keydelay: EQU 22h ; 2: Keyboard repeat delay +sysvar_keyrate: EQU 24h ; 2: Keyboard repeat reat +sysvar_keyled: EQU 26h ; 1: Keyboard LED status + +; Flags for the VPD protocol +; +vdp_pflag_cursor: EQU 00000001b +vdp_pflag_scrchar: EQU 00000010b +vdp_pflag_point: EQU 00000100b +vdp_pflag_audio: EQU 00001000b +vdp_pflag_mode: EQU 00010000b +vdp_pflag_rtc: EQU 00100000b + +; +; FatFS structures +; These mirror the structures contained in src_fatfs/ff.h in the MOS project +; +; Object ID and allocation information (FFOBJID) +; +FFOBJID .STRUCT + fs: DS 3 ; Pointer to the hosting volume of this object + id: DS 2 ; Hosting volume mount ID + attr: DS 1 ; Object attribute + stat: DS 1 ; Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) + sclust: DS 4 ; Object data start cluster (0:no cluster or root directory) + objsize: DS 4 ; Object size (valid when sclust != 0) +FFOBJID_SIZE .ENDSTRUCT FFOBJID +; +; File object structure (FIL) +; +FIL .STRUCT + obj: .TAG FFOBJID ; Object identifier + flag: DS 1 ; File status flags + err: DS 1 ; Abort flag (error code) + fptr: DS 4 ; File read/write pointer (Zeroed on file open) + clust: DS 4 ; Current cluster of fpter (invalid when fptr is 0) + sect: DS 4 ; Sector number appearing in buf[] (0:invalid) + dir_sect: DS 4 ; Sector number containing the directory entry + dir_ptr: DS 3 ; Pointer to the directory entry in the win[] +FIL_SIZE .ENDSTRUCT FIL +; +; Directory object structure (DIR) +; +DIR .STRUCT + obj: .TAG FFOBJID ; Object identifier + dptr: DS 4 ; Current read/write offset + clust: DS 4 ; Current cluster + sect: DS 4 ; Current sector (0:Read operation has terminated) + dir: DS 3 ; Pointer to the directory item in the win[] + fn: DS 12 ; SFN (in/out) {body[8],ext[3],status[1]} + blk_ofs: DS 4 ; Offset of current entry block being processed (0xFFFFFFFF:Invalid) +DIR_SIZE .ENDSTRUCT DIR +; +; File information structure (FILINFO) +; +FILINFO .STRUCT + fsize: DS 4 ; File size + fdate: DS 2 ; Modified date + ftime: DS 2 ; Modified time + fattrib: DS 1 ; File attribute + altname: DS 13 ; Alternative file name + fname: DS 256 ; Primary file name +FILINFO_SIZE .ENDSTRUCT FILINFO + +; +; Macro for calling the API +; Parameters: +; - function: One of the function numbers listed above +; +MOSCALL: MACRO function + LD A, function + RST.LIS 08h + ENDMACRO +; diff --git a/hexdump/output.asm b/hexdump/output.asm new file mode 100644 index 0000000..3f4650e --- /dev/null +++ b/hexdump/output.asm @@ -0,0 +1,54 @@ +; +; Title: Memory Dump - Output functions +; Author: Dean Belfield +; Created: 15/11/2022 +; Last Updated: 15/11/2022 +; +; Modinfo: + + INCLUDE "equs.inc" + + .ASSUME ADL = 0 + + SEGMENT CODE + + XDEF Print_Hex24 + XDEF Print_Hex16 + XDEF Print_Hex8 + + +; Print a 24-bit HEX number +; HLU: Number to print +; +Print_Hex24: PUSH.LIL HL + LD.LIL HL, 2 + ADD.LIL HL, SP + LD.LIL A, (HL) + POP.LIL HL + + CALL Print_Hex8 + +; Print a 16-bit HEX number +; HL: Number to print +; +Print_Hex16: LD A,H + CALL Print_Hex8 + LD A,L + +; Print an 8-bit HEX number +; A: Number to print +; +Print_Hex8: LD C,A + RRA + RRA + RRA + RRA + CALL $F + LD A,C +$$: AND 0Fh + ADD A,90h + DAA + ADC A,40h + DAA + RST 10h + RET \ No newline at end of file