├── .gitignore ├── BINTOASM.COM ├── DUMP.COM ├── HEXTOCOM.COM ├── PRL.COM ├── PRNTOSYM.COM ├── README.MD ├── RSX.COM ├── ZSM.COM ├── ZSMPP.COM ├── bintoasm.c ├── dump.c ├── hextobin.c ├── hextobin.com ├── hextocom.c ├── make_prl.bat ├── make_rsx.bat ├── prl.c ├── prntosym.c ├── releases ├── zsm20 │ ├── TEST1A.ASM │ ├── TEST2.ASM │ ├── Z80.DOC │ ├── Z80.LIB │ ├── Z80ASM.COM │ ├── Z80DOC.DOC │ ├── Z80MAIN.ASM │ ├── Z80OPCDS.ASM │ └── Z80SUBS.ASM ├── zsm24 │ ├── Z80ASMUK.ASM │ ├── Z80ASMUK.COM │ └── Z80DOCUK.DOC ├── zsm28 │ ├── ZSM.COM │ ├── ZSM.DOC │ ├── ZSM.ZSM │ └── ZSMTEST.ZSM ├── zsm29 │ ├── ZCHANGES.DOC │ ├── ZSM29.COM │ ├── ZSM29.DOC │ ├── ZSM29.ZSM │ └── ZSMTESTS.ZSM ├── zsm30 │ ├── CRASHZSM.ZSM │ ├── DUDOPS.ZSM │ ├── ZSM30.COM │ ├── ZSM30.TXT │ ├── ZSM30.ZSM │ ├── ZSMDOC.DOC │ ├── ZSMTST.ZSM │ └── ZSMTST2.ZSM ├── zsm31 │ ├── CRASHZSM.ZSM │ ├── DUDOPS.ZSM │ ├── ZSM31.COM │ ├── ZSM31.TXT │ ├── ZSM31.ZSM │ ├── ZSMDOC.DOC │ ├── ZSMTST.ZSM │ └── ZSMTST2.ZSM ├── zsm32 │ ├── CRASHZSM.ZSM │ ├── DUDOPS.ZSM │ ├── ZSM32.COM │ ├── ZSM32.TXT │ ├── ZSM32.ZSM │ ├── ZSMDOC.DOC │ ├── ZSMTST.ZSM │ └── ZSMTST2.ZSM ├── zsm33 │ ├── CRASHZSM.ZSM │ ├── DUDOPS.ZSM │ ├── ZSM33.COM │ ├── ZSM33.TXT │ ├── ZSM33.ZSM │ ├── ZSMDOC.DOC │ ├── ZSMTST.ZSM │ └── ZSMTST2.ZSM └── zsm34 │ ├── CRASHZSM.ZSM │ ├── DUDOPS.ZSM │ ├── ZSM34.COM │ ├── ZSM34.TXT │ ├── ZSM34.ZSM │ ├── ZSMDOC.DOC │ ├── ZSMTST.ZSM │ └── ZSMTST2.ZSM ├── rsx.c └── zsmpp.c /.gitignore: -------------------------------------------------------------------------------- 1 | # --------------------------- 2 | # MESCC & TOOL CHAIN BINARIES 3 | # --------------------------- 4 | cpm.exe 5 | cpm2.exe 6 | cpm_player.exe 7 | cc.com 8 | cc.COM 9 | CC.COM 10 | ccopt.com 11 | ccopt.COM 12 | CCOPT.COM 13 | #zsm.com 14 | #ZSM.COM 15 | #hextocom.com 16 | #hextocom.COM 17 | #HEXTOCOM.COM 18 | #link.com 19 | #LINK.COM 20 | #prntosym.com 21 | #prntosym.COM 22 | #PRNTOSYM.COM 23 | #zmac.exe 24 | 25 | # --------------- 26 | # MESCC LIBRARIES 27 | # --------------- 28 | alloc.h 29 | atexit.h 30 | bsearch.h 31 | clock.h 32 | conio.h 33 | cpm.h 34 | ctype.h 35 | fileio.h 36 | fprintf.h 37 | mem.h 38 | mescc.h 39 | printf.h 40 | qsort.h 41 | rand.h 42 | redir.h 43 | setjmp.h 44 | sprintf.h 45 | stdbool.h 46 | string.h 47 | xprintf.h 48 | z80.h 49 | 50 | # ------------------ 51 | # INTERMEDIATE FILES 52 | # ------------------ 53 | *.HEX 54 | *.ZSM 55 | *.PRN 56 | 57 | # ----------------------- 58 | # PROJECT FILES & FOLDERS 59 | # ----------------------- 60 | backup/ 61 | !releases/zsm*/*.ZSM -------------------------------------------------------------------------------- /BINTOASM.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiguelVis/zsm/00da4e7d1815dfadd9a7b74b051b3b56afdc7006/BINTOASM.COM -------------------------------------------------------------------------------- /DUMP.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiguelVis/zsm/00da4e7d1815dfadd9a7b74b051b3b56afdc7006/DUMP.COM -------------------------------------------------------------------------------- /HEXTOCOM.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiguelVis/zsm/00da4e7d1815dfadd9a7b74b051b3b56afdc7006/HEXTOCOM.COM -------------------------------------------------------------------------------- /PRL.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiguelVis/zsm/00da4e7d1815dfadd9a7b74b051b3b56afdc7006/PRL.COM -------------------------------------------------------------------------------- /PRNTOSYM.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiguelVis/zsm/00da4e7d1815dfadd9a7b74b051b3b56afdc7006/PRNTOSYM.COM -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | ZSM 2 | === 3 | 4 | ZSM, also known as Z80ASMUK, is a Z80 assembler for CP/M, that outputs HEX files. 5 | 6 | I like so much this assembler, so I have recopiled every ZSM version I could find over the Internet and my own disks. 7 | 8 | I have even contributed a bit to ZSM with code of my own, mainly patches. 9 | 10 | ![ZSM image](http://www.floppysoftware.es/images/cpm-zsm.jpg "ZSM image") 11 | 12 | Additional tools 13 | ---------------- 14 | 15 | I have developed some companion tools, in order to have a good native development tool chain for the Z80 assembler programming language under the CP/M operating system: 16 | - `zsmpp`: source code preprocessor for the ZSM assembler. 17 | - `bintoasm`: converts a binary file into an assembler file for ZSM. 18 | - `hextobin`: converts a HEX file into a binary file. 19 | - `hextocom`: converts an HEX file into a COM file for CP/M. 20 | - `prl`: makes PRL relocatable files from COM files. 21 | - `prntosym`: extracts symbols from a PRN file (from ZSM v2.8+) and generates an assembler file for ZSM. 22 | - `rsx`: manages RSX files. 23 | - `dump`: prints file contents in hexadecimal and ascii format. 24 | 25 | License 26 | ------- 27 | 28 | Reading the source code of ZSM, it seems there are various custom licenses involved. 29 | 30 | Regarding my companion tools, they are under the GPL license. -------------------------------------------------------------------------------- /RSX.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiguelVis/zsm/00da4e7d1815dfadd9a7b74b051b3b56afdc7006/RSX.COM -------------------------------------------------------------------------------- /ZSM.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiguelVis/zsm/00da4e7d1815dfadd9a7b74b051b3b56afdc7006/ZSM.COM -------------------------------------------------------------------------------- /ZSMPP.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiguelVis/zsm/00da4e7d1815dfadd9a7b74b051b3b56afdc7006/ZSMPP.COM -------------------------------------------------------------------------------- /bintoasm.c: -------------------------------------------------------------------------------- 1 | /* BinToAsm.c 2 | 3 | Converts a binary file into an assembler file for Z80. 4 | 5 | Copyright (C) 2004-2015 Miguel I. Garcia Lopez, FloppySoftware 6 | 7 | This program is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 2, or (at your option) any 10 | later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 20 | 21 | To compile with MESCC: 22 | 23 | cc bintoasm 24 | ccopt bintoasm.zsm 25 | zsm bintoasm 26 | hextocom bintoasm 27 | 28 | Revisions: 29 | 30 | 22 Feb 2004 : v1.00 31 | 03 Apr 2007 : v1.01 / Minor changes. 32 | 10 Apr 2007 : Output 8 bytes in a line instead of 16. 33 | 15 May 2007 : v1.02 / Added title & usage help. 34 | 04 Sep 2015 : v1.03 / Amended some messages and comments. 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #define VERSION "1.03 / 04 Sep 2015\n\n(c) 2004-2015 FloppySoftware" 46 | 47 | FILE *fpi, *fpo; 48 | 49 | int data, chpos; 50 | unsigned counter; 51 | 52 | main(argc, argv) 53 | int argc, argv[]; 54 | { 55 | printf("BinToAsm v%s\n\n", VERSION); 56 | 57 | if(argc!=3) 58 | { 59 | printf("Usage: bintoasm binfile asmfile\n"); 60 | exit(1); 61 | } 62 | 63 | if((fpi=fopen(argv[1],"rb"))==NULL) 64 | error("Opening input file"); 65 | 66 | if((fpo=fopen(argv[2],"w"))==NULL) 67 | error("Opening output file"); 68 | 69 | counter=chpos=0; 70 | 71 | while((data=fgetc(fpi))!=EOF) 72 | { 73 | if(!chpos) 74 | fprintf(fpo, " DEFB"); 75 | 76 | fprintf(fpo, " %03d", data); 77 | 78 | if(++chpos!=8) 79 | fprintf(fpo, ","); 80 | else 81 | { 82 | fprintf(fpo, "\n"); 83 | chpos=0; 84 | } 85 | 86 | ++counter; 87 | } 88 | 89 | printf("%d bytes\n", counter); 90 | 91 | if(fclose(fpi)) 92 | error("Closing input file"); 93 | 94 | if(fclose(fpo)) 95 | error("Closing output file"); 96 | } 97 | 98 | error(txt) 99 | char *txt; 100 | { 101 | printf("ERROR: %s\n", txt); 102 | exit(1); 103 | } 104 | -------------------------------------------------------------------------------- /dump.c: -------------------------------------------------------------------------------- 1 | /* dump.c 2 | 3 | Print contents of a file in byte and ascii format. 4 | 5 | (c) 2000-2015 Miguel I. Garcia Lopez, FloppySoftware. 6 | 7 | This program is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 2 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Usage: 22 | 23 | dump filename 24 | 25 | To compile with MESCC: 26 | 27 | cc dump 28 | ccopt dump.zsm 29 | zsm dump 30 | hextocom dump 31 | 32 | Revisions: 33 | 34 | ?? ?? 2000 : v1.00 35 | 10 Nov 2013 : v1.20 36 | 04 Sep 2015 : v1.21 : Amended some messages and comments. 37 | */ 38 | 39 | /* LIBRARIES 40 | */ 41 | 42 | #define CC_FREAD 43 | 44 | #include 45 | #include 46 | #include 47 | 48 | /* DEFs 49 | */ 50 | 51 | #define VERSION "Dump v1.21 / 04 Sep 2015\n\n(c) 2000-2015 FloppySoftware" 52 | 53 | /* PROGRAM 54 | */ 55 | 56 | main(argc,argv) 57 | int argc; 58 | int argv[]; 59 | { 60 | int i, /* Counter */ 61 | offset; /* Offset in file */ 62 | 63 | FILE *fp; /* Channel for file */ 64 | 65 | char buffer[16]; /* Buffer for input file */ 66 | 67 | /* Check right number of parameters */ 68 | 69 | if(argc != 2) 70 | { 71 | puts(VERSION); 72 | puts("\nUsage: dump fname"); 73 | return 1; 74 | } 75 | 76 | /* Open file in binary mode */ 77 | 78 | if((fp = fopen((argv[1]),"rb")) == NULL) 79 | error("Can't open file"); 80 | 81 | /* Initialize variables */ 82 | 83 | offset=0; 84 | 85 | /* Start */ 86 | 87 | while(fread(buffer, 16, 1, fp) == 1) 88 | { 89 | /* Print offset */ 90 | 91 | puthex4(offset); putchar(' '); putchar(':'); putchar(' '); 92 | 93 | /* Print data in hexadecimal format */ 94 | 95 | for(i = 0; i < 16; ++i) 96 | { 97 | puthex2(buffer[i]); putchar(' '); 98 | } 99 | 100 | /* Separator */ 101 | 102 | putchar(':'); putchar(' '); 103 | 104 | /* Print data in ascii format */ 105 | 106 | for(i = 0; i < 16; ++i) 107 | { 108 | if(buffer[i] > 31 && buffer[i] < 128) 109 | putchar(buffer[i]); 110 | else 111 | putchar('.'); 112 | } 113 | 114 | /* End of line */ 115 | 116 | putchar('\n'); 117 | 118 | /* Update offset */ 119 | 120 | offset += 16; 121 | } 122 | 123 | fclose(fp); 124 | 125 | return 0; 126 | } 127 | 128 | error(txt) 129 | char *txt; 130 | { 131 | puts(txt); 132 | 133 | exit(1); 134 | } 135 | 136 | puthex4(word) 137 | int word; 138 | { 139 | puthex2(word >> 8); 140 | puthex2(word); 141 | } 142 | 143 | puthex2(byte) 144 | char byte; 145 | { 146 | puthex1(byte >> 4); 147 | puthex1(byte); 148 | } 149 | 150 | puthex1(nibble) 151 | char nibble; 152 | { 153 | nibble &= 0x0F; 154 | 155 | putchar(nibble < 10 ? '0' + nibble : 'A' + nibble - 10); 156 | } 157 | 158 | -------------------------------------------------------------------------------- /hextobin.c: -------------------------------------------------------------------------------- 1 | /* hextobin.c 2 | 3 | Converts a HEX file into a binary file. 4 | Can be used to generate a COM file for CP/M if it is ORGed to 0x0100. 5 | 6 | (C) 2007-2015 Miguel I. Garcia Lopez, FloppySoftware. 7 | 8 | This program is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU General Public License as published by the 10 | Free Software Foundation; either version 2 of the License, or (at your 11 | option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 | 22 | Compile with MESCC: 23 | 24 | cc hextobin 25 | ccopt hextobin.zsm 26 | zsm hextobin 27 | hextocom hextobin 28 | 29 | Revisions: 30 | 31 | 18 Apr 2007 : v1.00 32 | 21 Apr 2007 : Shows first and last addresses, code size. 33 | 29 Apr 2007 : v1.01 34 | Bug showing code size upper than 0x8000 (shows 35 | negative number). Changed %d to %u to solve this bug. 36 | 15 Apr 2007 : v1.02 / Change usage text. 37 | 04 Sep 2015 : v1.03 / Modified some messages and comments. 38 | */ 39 | 40 | #include 41 | 42 | #include 43 | #include 44 | 45 | #define VERSION "1.03 / 04 Sep 2015\n\n(c) 2007-2015 FloppySoftware" 46 | 47 | #ifndef BYTE 48 | #define BYTE unsigned char 49 | #endif 50 | 51 | #ifndef WORD 52 | #define WORD unsigned int 53 | #endif 54 | 55 | FILE *fpi, /* HEX - Input file */ 56 | *fpo; /* COM - Output file */ 57 | 58 | BYTE chksum; /* Checksum of current line */ 59 | 60 | WORD adr, /* Load address */ 61 | ladr, /* Load address of current line */ 62 | first_adr; /* First address */ 63 | 64 | int lbytes, /* Number of data bytes of current line */ 65 | line, /* Number of current line */ 66 | run, /* Zero to exit program */ 67 | flag_adr; /* Zero if load address undefined */ 68 | 69 | /* Show error and exit 70 | */ 71 | 72 | error(txt) 73 | char *txt; 74 | { 75 | printf("ERROR: %s.\n", txt); 76 | exit(1); 77 | } 78 | 79 | /* Show error with line number and exit 80 | */ 81 | 82 | errorln(txt) 83 | char *txt; 84 | { 85 | printf("ERROR in line %d: %s.\n", line, txt); 86 | exit(1); 87 | } 88 | 89 | /* Read hex nibble 90 | */ 91 | 92 | BYTE getnib() 93 | { 94 | int c; 95 | 96 | c=fgetc(fpi); 97 | 98 | if(c>='0' && c<='9') 99 | return c-'0'; 100 | else if(c>='A' && c<='F') 101 | return c-'A'+10; 102 | else if(c==EOF) 103 | error("Unexpected EOF"); 104 | else 105 | error("Bad hex digit"); 106 | } 107 | 108 | /* Read two hex nibbles 109 | */ 110 | 111 | BYTE gethex() 112 | { 113 | BYTE nib, hex; 114 | 115 | nib=getnib(); 116 | 117 | chksum+=(hex=(nib << 4) + getnib()); 118 | 119 | return hex; 120 | } 121 | 122 | /* Write byte 123 | */ 124 | 125 | putbyte(byte) 126 | BYTE byte; 127 | { 128 | if(fputc(byte, fpo)==EOF) 129 | error("Writing binfile"); 130 | } 131 | 132 | /* Main 133 | */ 134 | 135 | main(argc, argv) 136 | int argc, argv[]; 137 | { 138 | int c; 139 | 140 | printf("HexToBin v%s\n\n", VERSION); 141 | 142 | if(argc!=3) 143 | { 144 | printf("Usage: hextobin hexfile binfile\n"); 145 | exit(1); 146 | } 147 | 148 | if((fpi=fopen(argv[1], "r"))==NULL) 149 | error("Opening hexfile"); 150 | 151 | if((fpo=fopen(argv[2], "wb"))==NULL) 152 | error("Opening binfile"); 153 | 154 | first_adr=adr=0; /* Load address */ 155 | line=run=1; /* Line number and loop variable */ 156 | flag_adr=0; /* Load address undefined */ 157 | 158 | while((c=fgetc(fpi))!=EOF && run) 159 | { 160 | if(c!=':') 161 | errorln("Missing colon"); 162 | 163 | chksum=0; 164 | 165 | lbytes=gethex(); /* Bytes per line */ 166 | 167 | ladr=gethex(); 168 | ladr=(ladr<<8)+gethex(); /* Load adress */ 169 | 170 | switch(gethex()) /* Line type */ 171 | { 172 | case 0 : /* Data */ 173 | if(!lbytes) 174 | break; 175 | 176 | if(!flag_adr) 177 | { 178 | first_adr=adr=ladr; 179 | ++flag_adr; 180 | } 181 | else if(adrladr) 190 | errorln("Bad address"); 191 | 192 | adr+=lbytes; 193 | 194 | while(lbytes--) 195 | putbyte(gethex()); 196 | break; 197 | case 1 : /* End */ 198 | run=0; 199 | break; 200 | default : 201 | errorln("Unknown record type"); 202 | } 203 | 204 | gethex(); /* Checksum */ 205 | 206 | if(chksum) 207 | errorln("Bad checksum"); 208 | 209 | if((c=fgetc(fpi))!='\n') 210 | errorln("Missing newline"); 211 | 212 | ++line; 213 | } 214 | 215 | if(fclose(fpi)) 216 | error("Closing hexfile"); 217 | 218 | if(fclose(fpo)) 219 | error("Closing binfile"); 220 | 221 | printf("First address: %04x\n", first_adr); 222 | printf("Last address: %04x\n", adr-1); 223 | printf("Size of code: %04x (%u dec) bytes\n", adr-first_adr, adr-first_adr); 224 | 225 | } 226 | -------------------------------------------------------------------------------- /hextobin.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiguelVis/zsm/00da4e7d1815dfadd9a7b74b051b3b56afdc7006/hextobin.com -------------------------------------------------------------------------------- /hextocom.c: -------------------------------------------------------------------------------- 1 | /* hextocom.c 2 | 3 | Converts an HEX file into a COM file for CP/M. 4 | 5 | (C) 2007-2016 FloppySoftware (Miguel I. Garcia Lopez, Spain). 6 | 7 | This program is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 2 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | To compile with MESCC: 22 | 23 | cc hextocom 24 | ccopt hextocom.zsm 25 | zsm hextocom 26 | hextocom hextocom 27 | 28 | Revisions: 29 | 30 | (hextobin.c) 31 | 32 | 18 Apr 2007 : v1.00 : 33 | 21 Apr 2007 : : Shows first and last addresses, code size. 34 | 29 Apr 2007 : v1.01 : Bug showing code size upper than 0x8000 (shows 35 | negative number). Changed %d to %u to solve this bug. 36 | 15 May 2007 : v1.02 : Change usage text. 37 | 38 | (hextocom.c) 39 | 40 | 13 Nov 2014 : v1.03 : Modified to generate COM files for CP/M. 41 | 04 Sep 2015 : v1.04 : Modified some comments and messages. 42 | 10 Jan 2016 : v1.05 : Cleaned. 43 | */ 44 | 45 | /* Defines for MESCC libraries 46 | --------------------------- 47 | */ 48 | #define CC_FILEIO_SMALL // Exclude fread(), fwrite() and fgets(). 49 | 50 | /* Standard MESCC library 51 | ---------------------- 52 | */ 53 | #include 54 | 55 | /* Standard MESCC libraries 56 | ------------------------ 57 | */ 58 | #include 59 | #include 60 | #include 61 | 62 | /* Project defs. 63 | ------------- 64 | */ 65 | #define APP_NAME "HexToCom" 66 | #define APP_VERSION "v1.05 / 10 Jan 2016" 67 | #define APP_COPYRGT "(c) 2007-2016 FloppySoftware" 68 | #define APP_USAGE "HexToCom filename" 69 | 70 | /* Globals 71 | ------- 72 | */ 73 | FILE *fpi, /* HEX - Input file */ 74 | *fpo; /* COM - Output file */ 75 | 76 | BYTE chksum; /* Checksum of current line */ 77 | 78 | WORD adr, /* Load address */ 79 | ladr, /* Load address of current line */ 80 | first_adr; /* First address */ 81 | 82 | int lbytes, /* Number of data bytes of current line */ 83 | line, /* Number of current line */ 84 | run, /* Zero to exit program */ 85 | flag_adr; /* Zero if load address undefined */ 86 | 87 | char fn_hex[FILENAME_MAX], /* HEX - filename */ 88 | fn_com[FILENAME_MAX]; /* COM - filename */ 89 | 90 | /* Print error and exit 91 | -------------------- 92 | */ 93 | error(txt) 94 | char *txt; 95 | { 96 | printf("%s: %s.\n", APP_NAME, txt); 97 | exit(-1); 98 | } 99 | 100 | /* Print error with line number and exit 101 | ------------------------------------- 102 | */ 103 | errorln(txt) 104 | char *txt; 105 | { 106 | printf("%s: Error in line %d - %s.\n", APP_NAME, line, txt); 107 | exit(-1); 108 | } 109 | 110 | /* Read hex nibble 111 | --------------- 112 | */ 113 | BYTE getnib() 114 | { 115 | int c; 116 | 117 | c=fgetc(fpi); 118 | 119 | if(c>='0' && c<='9') 120 | return c-'0'; 121 | 122 | if(c>='A' && c<='F') 123 | return c-'A'+10; 124 | 125 | if(c==EOF) 126 | error("Unexpected EOF"); 127 | 128 | error("Bad hexadecimal digit"); 129 | } 130 | 131 | /* Read two hex nibbles 132 | -------------------- 133 | */ 134 | BYTE gethex() 135 | { 136 | BYTE nib, hex; 137 | 138 | nib=getnib(); 139 | 140 | chksum+=(hex=(nib << 4) + getnib()); 141 | 142 | return hex; 143 | } 144 | 145 | /* Write byte 146 | ---------- 147 | */ 148 | putbyte(byte) 149 | BYTE byte; 150 | { 151 | if(fputc(byte, fpo)==EOF) 152 | error("Writing COM file"); 153 | } 154 | 155 | /* Main 156 | ---- 157 | */ 158 | main(argc, argv) 159 | int argc, argv[]; 160 | { 161 | /* Program name, copyright, etc. */ 162 | 163 | printf("%s %s\n\n", APP_NAME, APP_VERSION); 164 | printf("%s\n\n", APP_COPYRGT); 165 | 166 | /* Show usage? */ 167 | 168 | if(argc != 2) 169 | { 170 | printf("Usage: %s\n", APP_USAGE); 171 | exit(0); 172 | } 173 | 174 | /* Filenames */ 175 | 176 | if(strchr(argv[1], '.') != NULL) 177 | error("Bad filename (no type, please)"); 178 | 179 | if(strlen(argv[1]) > 10) /* D:FILENAME */ 180 | error("Bad filename (too long)"); 181 | 182 | strcat(strcpy(fn_hex, argv[1]), ".HEX"); 183 | strcat(strcpy(fn_com, argv[1]), ".COM"); 184 | 185 | /* Open files */ 186 | 187 | if((fpi=fopen(fn_hex, "r"))==NULL) 188 | error("Opening HEX file"); 189 | 190 | if((fpo=fopen(fn_com, "wb"))==NULL) 191 | error("Opening COM file"); 192 | 193 | /* Start process */ 194 | 195 | first_adr=adr=0; /* Load address */ 196 | line=run=1; /* Line number and loop variable */ 197 | flag_adr=0; /* Load address undefined */ 198 | 199 | while(run) 200 | { 201 | if(fgetc(fpi) != ':') 202 | errorln("Missing colon"); 203 | 204 | chksum=0; 205 | 206 | lbytes=gethex(); /* Bytes per line */ 207 | 208 | ladr=gethex(); 209 | ladr=(ladr<<8)+gethex(); /* Load adress */ 210 | 211 | switch(gethex()) /* Line type */ 212 | { 213 | case 0 : /* Data */ 214 | if(!lbytes) 215 | { 216 | run = 0; 217 | break; 218 | } 219 | 220 | if(!flag_adr) 221 | { 222 | if((first_adr=adr=ladr) != 0x0100) 223 | error("Start address must be 0100H"); 224 | 225 | ++flag_adr; 226 | } 227 | else if(adrladr) 236 | errorln("Bad address"); 237 | 238 | adr+=lbytes; 239 | 240 | while(lbytes--) 241 | putbyte(gethex()); 242 | break; 243 | case 1 : /* End */ 244 | run=0; 245 | break; 246 | default : 247 | errorln("Unknown record type"); 248 | break; 249 | } 250 | 251 | gethex(); /* Checksum */ 252 | 253 | if(chksum) 254 | errorln("Bad checksum"); 255 | 256 | if(fgetc(fpi)!='\n') 257 | errorln("Missing newline"); 258 | 259 | ++line; 260 | } 261 | 262 | /* Close files */ 263 | 264 | if(fclose(fpi)) 265 | error("Closing HEX file"); 266 | 267 | if(fclose(fpo)) 268 | error("Closing COM file"); 269 | 270 | /* Print facts */ 271 | 272 | printf("First address: %04x\n", first_adr); 273 | printf("Last address: %04x\n", adr-1); 274 | printf("Size of code: %04x (%u dec) bytes\n", adr-first_adr, adr-first_adr); 275 | 276 | } 277 | -------------------------------------------------------------------------------- /make_prl.bat: -------------------------------------------------------------------------------- 1 | cpm cc prl 2 | cpm ccopt prl 3 | cpm zsm prl 4 | cpm hextocom prl -------------------------------------------------------------------------------- /make_rsx.bat: -------------------------------------------------------------------------------- 1 | cpm cc rsx 2 | cpm ccopt rsx 3 | cpm zsm rsx 4 | cpm hextocom rsx -------------------------------------------------------------------------------- /prl.c: -------------------------------------------------------------------------------- 1 | /* prl.c 2 | 3 | Make PRL file. 4 | 5 | Copyright (c) 2016 Miguel Garcia / FloppySoftware 6 | 7 | This program is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 3, or (at your option) any 10 | later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 20 | 21 | Author's contact: 22 | 23 | www.floppysoftware.es 24 | cpm-connections.blogspot.com 25 | floppysoftware@gmail.com 26 | 27 | To compile with MESCC: 28 | 29 | cc prl 30 | ccopt prl 31 | zsm prl 32 | hextocom prl 33 | 34 | Usage: 35 | 36 | prl filename[.com] filename[.com] filename[.prl] 37 | 38 | Revisions: 39 | 40 | 23 Nov 2016 : Start. 41 | */ 42 | 43 | /* Defines for MESCC libraries 44 | --------------------------- 45 | */ 46 | #define CC_FREAD // Include fread() 47 | #define CC_FWRITE // Include fwrite() 48 | 49 | /* Standard MESCC library 50 | ---------------------- 51 | */ 52 | #include 53 | 54 | /* Standard MESCC libraries 55 | ------------------------ 56 | */ 57 | #include 58 | //#include 59 | //#include 60 | //#include 61 | //#include 62 | #include // For get_rsize() 63 | //#include 64 | #include 65 | //#include 66 | #include 67 | #include 68 | //#include 69 | //#include 70 | //#include 71 | //#include 72 | //#include 73 | //#include 74 | //#include 75 | //#include 76 | 77 | /* Project defs. 78 | ------------- 79 | */ 80 | #define APP_NAME "PRL" 81 | #define APP_VERSION "v1.00 / 18 Nov 2016" 82 | #define APP_COPYRGT "(c) 2016 FloppySoftware" 83 | #define APP_USAGE "prl filename[.com] filename[.com] filename[.prl]" 84 | 85 | #define TMP_FNAME "prl.$$$" 86 | 87 | #define PRL_HEADER_SIZE 256 88 | 89 | #define PRL_H_BYTES 1 // WORD: Bytes in program image (code + initialised data) 90 | #define PRL_H_BSS 4 // WORD: Bytes reserved for unitialised data 91 | #define PRL_H_LADR 7 // WORD: Load address 92 | #define PRL_H_CBASE 10 // WORD: BIOS link 93 | 94 | /* Globals 95 | ------- 96 | */ 97 | int task = -1; 98 | 99 | char cm1_fname[FILENAME_MAX]; 100 | char cm2_fname[FILENAME_MAX]; 101 | char prl_fname[FILENAME_MAX]; 102 | char tmp_fname[FILENAME_MAX]; 103 | 104 | FILE *cm1_fp; 105 | FILE *cm2_fp; 106 | FILE *tmp_fp; 107 | 108 | BYTE prl_header[PRL_HEADER_SIZE]; 109 | 110 | /* Program entry 111 | ------------- 112 | */ 113 | main(argc, argv) 114 | int argc; 115 | unsigned int argv[]; // char *argv[] - unsupported by MESCC (yet?) 116 | { 117 | // Show usage if there are no arguments 118 | if(argc == 1) 119 | { 120 | usage(); 121 | } 122 | 123 | // Check arguments 124 | if(argc != 4) 125 | { 126 | error_bad_cmdline(); 127 | } 128 | 129 | // Take COM filename #1 130 | get_fname(cm1_fname, argv[1], "COM"); 131 | 132 | // Take COM filename #2 133 | get_fname(cm2_fname, argv[2], "COM"); 134 | 135 | // Take PRL filename 136 | get_fname(prl_fname, argv[3], "PRL"); 137 | 138 | // Take TMP filename 139 | get_temp_fname(prl_fname); 140 | 141 | // Process 142 | process(); 143 | 144 | // Success 145 | exit(0); 146 | } 147 | 148 | /* Process files 149 | ------------- 150 | */ 151 | process() 152 | { 153 | WORD recs, *pw; 154 | int i, k, b, h, bitmap_size; 155 | BYTE rec_bf1[128], rec_bf2[128], *pb_bitmap, byte, mask; 156 | 157 | // Open COM filename #1 158 | if(!(cm1_fp = fopen(cm1_fname, "rb"))) 159 | { 160 | error_open(); 161 | } 162 | 163 | // Open COM filename #2 164 | if(!(cm2_fp = fopen(cm2_fname, "rb"))) 165 | { 166 | error_open(); 167 | } 168 | 169 | // Open TMP filename 170 | if(!(tmp_fp = fopen(tmp_fname, "wb"))) 171 | { 172 | error_open(); 173 | } 174 | 175 | // Get COM file size in CP/M records 176 | if(!(recs = get_rsize(cm1_fname))) 177 | { 178 | error("File is empty"); 179 | } 180 | 181 | // Check valid file size 182 | if(recs > 512) 183 | { 184 | error("File is too big"); 185 | } 186 | 187 | // Check size coincidence between both COM files 188 | if(recs != get_rsize(cm2_fname)) 189 | { 190 | error("Files differ in size"); 191 | } 192 | 193 | // Alloc memory for relocation bitmap 194 | bitmap_size = recs * 16; 195 | 196 | if(!(pb_bitmap = malloc(bitmap_size))) 197 | { 198 | error("No memory for relocation bitmap"); 199 | } 200 | 201 | // Initialize PRL header 202 | *(pw = prl_header + PRL_H_BYTES) = recs * 128; 203 | 204 | // Write PRL header 205 | if(fwrite(prl_header, PRL_HEADER_SIZE, 1, tmp_fp) != 1) 206 | { 207 | error_write(); 208 | } 209 | 210 | // Write COM file #1 contents to TMP -- FIXME -- try to speed up this! 211 | for(i = b = 0; i < recs; ++i) 212 | { 213 | if(fread(rec_bf1, 128, 1, cm1_fp) != 1) 214 | { 215 | error_read(); 216 | } 217 | 218 | if(fwrite(rec_bf1, 128, 1, tmp_fp) != 1) 219 | { 220 | error_write(); 221 | } 222 | 223 | if(fread(rec_bf2, 128, 1, cm2_fp) != 1) 224 | { 225 | error_read(); 226 | } 227 | 228 | for(k = 0; k < 128; k += 8) 229 | { 230 | mask = 128; 231 | 232 | for(h = byte = 0; h < 8; ++h) 233 | { 234 | if(rec_bf1[k + h] != rec_bf2[k + h]) 235 | { 236 | byte |= mask; 237 | } 238 | 239 | mask = mask >> 1; 240 | } 241 | 242 | pb_bitmap[b++] = byte; 243 | } 244 | } 245 | 246 | // Write PRL relocation bitmap to TMP 247 | if(fwrite(pb_bitmap, bitmap_size, 1, tmp_fp) != 1) 248 | { 249 | error_write(); 250 | } 251 | 252 | // Close COM filename #1 253 | fclose(cm1_fp); 254 | 255 | // Close COM filename #2 256 | fclose(cm2_fp); 257 | 258 | // Close TMP filename 259 | if(fclose(tmp_fp)) 260 | { 261 | error_close(); 262 | } 263 | 264 | // Delete old PRL file if exists 265 | remove(prl_fname); 266 | 267 | // Rename TMP file to PRL filename 268 | if(rename(tmp_fname, prl_fname)) 269 | { 270 | error("Can't rename file"); 271 | } 272 | } 273 | 274 | /* Copy a filename and add a file type if needed 275 | --------------------------------------------- 276 | */ 277 | get_fname(dest, fname, ftype) 278 | char *dest, *fname, *ftype; 279 | { 280 | int len_type; 281 | 282 | len_type = (strchr(fname, '.') ? 0 : strlen(ftype) + 1); 283 | 284 | if(strlen(fname) + len_type >= FILENAME_MAX) 285 | { 286 | error_fname(); 287 | } 288 | 289 | strcpy(dest, fname); 290 | 291 | if(len_type) 292 | { 293 | strcat(dest, "."); strcat(dest, ftype); 294 | } 295 | } 296 | 297 | /* Generate temporary filename 298 | --------------------------- 299 | */ 300 | get_temp_fname(fname) 301 | char *fname; 302 | { 303 | char *pc; 304 | int k; 305 | 306 | pc = strchr(fname, ':'); 307 | 308 | k = (pc ? pc - fname + 1 : 0); 309 | 310 | pc = TMP_FNAME; 311 | 312 | if(k + strlen(pc) >= FILENAME_MAX) 313 | { 314 | error_fname(); 315 | } 316 | 317 | if(k) 318 | { 319 | memcpy(tmp_fname, fname, k); 320 | } 321 | 322 | strcpy(tmp_fname + k, pc); 323 | } 324 | 325 | /* Get file size in records of 128 bytes each 326 | ------------------------------------------ 327 | */ 328 | get_rsize(fname) 329 | char *fname; 330 | { 331 | BYTE fcb[36]; 332 | WORD *pw; 333 | 334 | if(!setfcb(fname, fcb)) 335 | { 336 | if(!bdos_a(BF_FSIZE, fcb)) 337 | { 338 | return *(pw = fcb + 33); 339 | } 340 | } 341 | 342 | error("Can't get file size"); 343 | } 344 | 345 | /* Show usage and exit 346 | ------------------- 347 | */ 348 | usage() 349 | { 350 | printf("%s %s - %s\n\n", APP_NAME, APP_VERSION, APP_COPYRGT); 351 | printf("Make PRLs - Page ReLocatable files.\n\n"); 352 | printf("Usage: %s\n\n", APP_USAGE); 353 | 354 | exit(0); 355 | } 356 | 357 | /* Print error and exit 358 | -------------------- 359 | */ 360 | error(msg) 361 | char *msg; 362 | { 363 | printf("%s: %s\n", APP_NAME, msg); 364 | 365 | exit(-1); 366 | } 367 | 368 | /* Error: bad command line 369 | ----------------------- 370 | */ 371 | error_bad_cmdline() 372 | { 373 | error("Bad command line"); 374 | } 375 | 376 | /* Error: filename too long 377 | ------------------------ 378 | */ 379 | error_fname() 380 | { 381 | error("Filename is too long"); 382 | } 383 | 384 | /* Error: can't open file 385 | ---------------------- 386 | */ 387 | error_open() 388 | { 389 | error("Can't open file"); 390 | } 391 | 392 | /* Error: can't close file 393 | ----------------------- 394 | */ 395 | error_close() 396 | { 397 | error("Can't close file"); 398 | } 399 | 400 | /* Error: reading file 401 | ------------------- 402 | */ 403 | error_read() 404 | { 405 | error("Reading file"); 406 | } 407 | 408 | /* Error: writing file 409 | ------------------- 410 | */ 411 | error_write() 412 | { 413 | error("Writing file"); 414 | } 415 | 416 |  -------------------------------------------------------------------------------- /prntosym.c: -------------------------------------------------------------------------------- 1 | /* prntosym.c 2 | 3 | Extract symbols from a PRN file (from ZSM v2.8). 4 | 5 | (C) 2015 FloppySoftware (Miguel I. Garcia Lopez, Spain). 6 | 7 | This program is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 2 of the License, or (at your 10 | option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | CONTACT: 22 | 23 | www.floppysoftware.vacau.com 24 | cpm-connections.blogspot.com 25 | floppysoftware@gmail.com 26 | 27 | USAGE: 28 | 29 | prntosym source [> destination] 30 | 31 | TO COMPILE WITH MESCC: 32 | 33 | cc prntosym 34 | ccopt prntosym.zsm 35 | zsm prntosym 36 | hextocom prntosym 37 | 38 | REVISIONS: 39 | 40 | 20 Aug 2015 : v1.00 : Initial version. 41 | 21 Aug 2015 : v1.01 : Added SKIP_INTERNAL and SKIP_SAMARUX defines. 42 | Added EXIT to skipped symbol names in SamaruX. 43 | 24 Aug 2015 : v1.02 : Minor changes in file output. 44 | 04 Sep 2015 : v1.03 : Modified some comments and messages. 45 | 46 | NOTES: 47 | 48 | It was developed to support SamaruX external commands, but it can be useful on other matters too. 49 | 50 | It skips some symbol names, if you define: 51 | 52 | SKIP_INTERNAL : To skip symbols finishing with a decimal digit, like 'a32' (MESCC internal ones). 53 | 54 | SKIP_SAMARUX : To skip following symbols: 55 | 56 | CCFREEMEM 57 | EXIT 58 | MAIN 59 | */ 60 | 61 | /* MESCC DEFs 62 | */ 63 | 64 | #define CC_STDIO /* Support for stdin, stdout, stderr */ 65 | #define CC_REDIR /* Support for command line redirection */ 66 | 67 | #define CC_NO_SWITCH /* No switch */ 68 | 69 | /* MESCC libraries 70 | */ 71 | 72 | #include 73 | #include 74 | #include 75 | #include 76 | #include 77 | #include 78 | #include 79 | #include 80 | 81 | /* DEFs and globals 82 | */ 83 | 84 | #define SKIP_INTERNAL 85 | #define SKIP_SAMARUX 86 | 87 | #define VERSION "1.03 / 04 Sep 2015\n\n(c) 2015 FloppySoftware" 88 | 89 | #define BUF_LEN 127 /* Max. lenght for input buffer */ 90 | #define BUF_SIZ 128 /* Size for input buffer */ 91 | 92 | FILE *fp; /* Input file FP */ 93 | char buf[BUF_SIZ]; /* Input buffer */ 94 | 95 | /* Main 96 | */ 97 | 98 | main(argc, argv) 99 | int argc, argv[]; 100 | { 101 | /* Show banner */ 102 | 103 | fprintf(stderr, "PrnToSym v%s\n\n", VERSION); 104 | 105 | /* Check arguments */ 106 | 107 | if(argc != 2) 108 | { 109 | fprintf(stderr, "Usage: prntosym inputfile [> outputfile]\n"); 110 | exit(1); 111 | } 112 | 113 | /* Process input file */ 114 | 115 | procfile(argv[1]); 116 | 117 | /* End */ 118 | 119 | fprintf(stderr, "Done.\n"); 120 | } 121 | 122 | /* Process input file 123 | */ 124 | 125 | procfile(fn) 126 | char *fn; 127 | { 128 | int k, flag; 129 | 130 | /* Open file */ 131 | 132 | if((fp = fopen(fn, "r")) == NULL) 133 | error("Opening input file"); 134 | 135 | /* Process file */ 136 | 137 | flag = 0; 138 | 139 | while(1) 140 | { 141 | /* Read line */ 142 | 143 | if(fgets(buf, BUF_SIZ, fp) == NULL) 144 | break; 145 | 146 | /* Check EOL */ 147 | 148 | k = strlen(buf); 149 | 150 | if(buf[--k] != '\n') 151 | error("Line too long or missing newline"); 152 | 153 | /* Clear LF and put a ZERO instead */ 154 | 155 | buf[k] = 0; 156 | 157 | /* Process line */ 158 | 159 | if(flag) 160 | procline(); 161 | else if(!memcmp(buf, "Next", 4)) /* ie: Next address: CE05H */ 162 | ++flag; 163 | } 164 | 165 | /* Close file */ 166 | 167 | fclose(fp); 168 | } 169 | 170 | /* Process input line 171 | */ 172 | 173 | procline() 174 | { 175 | char *p, name[12], adr[5]; 176 | int k, x; 177 | 178 | /* Link to line */ 179 | 180 | p = buf; 181 | 182 | /* Can be an empty or title line */ 183 | 184 | if(*p == 12 || !(*p)) 185 | return; 186 | 187 | /* Each line can hold up to 4 symbols: */ 188 | 189 | /* NUMBER 52C5 NXTLAB BC5D OPFNAME BC7C ORFN 6144 */ 190 | 191 | while(isalpha(*p) || *p == '_') 192 | { 193 | /* Symbol name */ 194 | 195 | k = 0; 196 | 197 | do { 198 | name[k++] = *p++; 199 | 200 | if(k == 12) 201 | error("Symbol name too long"); 202 | 203 | } while(isalpha(*p) || *p == '_' || isdigit(*p)); 204 | 205 | name[k] = 0; 206 | 207 | /* Skip blanks */ 208 | 209 | while(*p == ' ' || *p == '\t') 210 | ++p; 211 | 212 | /* Address */ 213 | 214 | x = 0; 215 | 216 | while(isxdigit(*p)) { 217 | adr[x++] = *p++; 218 | 219 | if(x == 5) 220 | error("Bad symbol address"); 221 | } 222 | 223 | adr[x] = 0; 224 | 225 | /* Skip blanks */ 226 | 227 | while(*p == ' ' || *p == '\t') 228 | ++p; 229 | 230 | #ifdef SKIP_INTERNAL 231 | /* Skip symbols finishing with a decimal digit (MESCC internal ones) */ 232 | 233 | if(isdigit(name[k - 1])) 234 | continue; 235 | #endif 236 | 237 | #ifdef SKIP_SAMARUX 238 | /* Skip some symbols for SamaruX external commands */ 239 | 240 | if(!strcmp(name, "CCFREEMEM")) 241 | continue; 242 | 243 | if(!strcmp(name, "EXIT")) 244 | continue; 245 | 246 | if(!strcmp(name, "MAIN")) 247 | continue; 248 | #endif 249 | 250 | /* Print symbol and address */ 251 | 252 | fprintf(stdout, "%-12s equ 0%sH\n", name, adr); 253 | } 254 | 255 | /* Check EOL */ 256 | 257 | if(*p) 258 | error("Bad line format"); 259 | } 260 | 261 | /* Print error and exit 262 | */ 263 | 264 | error(txt) 265 | char *txt; 266 | { 267 | fprintf(stderr, "ERROR: %s.\n", txt); exit(1); 268 | } 269 | -------------------------------------------------------------------------------- /releases/zsm20/TEST1A.ASM: -------------------------------------------------------------------------------- 1 | ; 2 | ; Z80 ASSEMBLER TEST INSTRUCTION FILE 3 | ; 4 | ORG 100H ;TEST ORG PSEUDO OP 5 | LABEL1 EQU $ ;TEST EQU PSEUDO OP 6 | DEFW LABEL1 ;TEST DEFW PSEUDO OP 7 | DEFB 03FH ;TEST DEFB PSEUDO OP FORM 1 8 | DEFB 'THIS IS A TEST' ;TEST DEFB PSEUDO OP FORM 2 9 | DEFS 55 ;TEST DEFS PSEUDO OP 10 | ; 11 | ; THE NEXT THREE LINES USE THE IBM PSEUDO WHICH WAS ADDED TO 12 | ; FACILITATE SCREEN FORMATTING. 13 | ; 14 | ; THE FORMAT IS: IBM HEX,ASCII,HEX,ASCII,... WITH NO QUOTES 15 | ; AROUND THE ASCII 16 | ; 17 | ; IF THE USER WHISHES TO USE ASCII FIRST THEN THE FIRST BYTE MUST 18 | ; BEGIN WITH A QUOTE. 19 | ; 20 | ; THE HEX NUMBERS MUST BE IN PAIRS AND MUST NOT HAVE 'H' AFTER THEM 21 | ; THE ASCII STRINGS CAN INCLUDE ANY CHARACTERS (INCLUDING QUOTES AND 22 | ; SEMI-COLONS EXCEPT NO COMMAS 23 | ; 24 | ; 25 | ; 26 | IBM 1A0000,TOP OF SCREEN ON LEAR SEIGLER ADM3,0D0A0D0A,DOWN 3 LINES 27 | IBM 0FAD,ASCII CODING,0FE4,SCREEN FORMATTING 28 | IBM 'ASCII FIRST,0DFF,THEN HEX 29 | ; 30 | LD A,B ;TEST LOAD 31 | LD A,0FFH 32 | LD A,(HL) 33 | LD A,(IX+5) 34 | LD A,(IY+6) 35 | LD (HL),B 36 | LD (IX+5),B 37 | LD (IY+5),B 38 | LD (HL),23 39 | LD (IX+1),24 40 | LD (IY+1),25 41 | LD (BC),A 42 | LD (DE),A 43 | LD (LABEL1),A 44 | LD A,(BC) 45 | LD A,(DE) 46 | LD A,(LABEL1) 47 | LD A,I 48 | LD A,R 49 | LD I,A 50 | LD R,A 51 | LD BC,LABEL1 52 | LD DE,LABEL1 53 | LD HL,LABEL1 54 | LD SP,LABEL1 55 | LD IX,LABEL1 56 | LD IY,LABEL1 57 | LD HL,(LABEL1) 58 | LD IX,(LABEL1) 59 | LD IY,(LABEL1) 60 | LD (LABEL1),HL 61 | LD (LABEL1),BC 62 | LD (LABEL1),DE 63 | LD (LABEL1),IX 64 | LD (LABEL1),IY 65 | LD SP,HL 66 | LD SP,IX 67 | LD SP,IY 68 | PUSH BC 69 | PUSH DE 70 | PUSH HL 71 | PUSH AF 72 | PUSH IX 73 | PUSH IY 74 | POP BC 75 | POP DE 76 | POP HL 77 | POP IX 78 | POP IY 79 | POP AF 80 | EX DE,HL 81 | EX AF,AF' 82 | EXX 83 | EX (SP),HL 84 | EX (SP),IX 85 | EX (SP),IY 86 | LDI 87 | LDIR 88 | LDD 89 | LDDR 90 | CPI 91 | CPIR 92 | CPD 93 | CPDR 94 | ADD A 95 | ADD 0FFH 96 | ADD (HL) 97 | ADD (IX+5) 98 | ADD (IY+6) 99 | ADC A 100 | SUB A 101 | SBC A 102 | AND A 103 | OR A 104 | XOR A 105 | CP A 106 | INC A 107 | INC (HL) 108 | INC (IX+3) 109 | INC (IY+5) 110 | DEC (HL) 111 | DAA 112 | CPL 113 | NEG 114 | CCF 115 | SCF 116 | NOP 117 | HALT 118 | DI 119 | EI 120 | IM0 121 | IM1 122 | IM2 123 | ADD HL,BC 124 | ADC HL,DE 125 | SBC HL,DE 126 | ADD IX,BC 127 | ADD IY,DE 128 | INC IX 129 | INC IY 130 | DEC IX 131 | DEC IY 132 | RLCA 133 | RLA 134 | RRCA 135 | RRA 136 | RLC B 137 | 138 | RLC (HL) 139 | RLC (IX+5) 140 | RLC (IY+4) 141 | RL B 142 | RRC B 143 | RR B 144 | SLA B 145 | SRA B 146 | SRL B 147 | RLD 148 | RRD 149 | BIT 5,E 150 | BIT 5,(HL) 151 | BIT 5,(IX+5) 152 | BIT 5,(IY+4) 153 | SET 4,B 154 | SET 4,(HL) 155 | SET 4,(IX+5) 156 | SET 4,(IY+4) 157 | RES 4,E 158 | RES 4,(HL) 159 | JP LABEL1 160 | JP NZ,LABEL1 161 | JP C,LABEL1 162 | JR +6 163 | JR C,5 164 | JR NC,5 165 | JR Z,5 166 | JR NZ,5 167 | JP (HL) 168 | JP (IX) 169 | JP (IY) 170 | DJNZ 5 171 | CALL LABEL1 172 | CALL NZ,LABEL1 173 | RET 174 | RET NZ 175 | RETI 176 | RETN 177 | RST 38H 178 | IN A,(03H) 179 | IN B,(C) 180 | INI 181 | INIR 182 | IND 183 | INDR 184 | OUT (034H),A 185 | OUT (C),E 186 | OUTI 187 | OTIR 188 | OUTD 189 | OTDR 190 | END $ 191 |  -------------------------------------------------------------------------------- /releases/zsm20/TEST2.ASM: -------------------------------------------------------------------------------- 1 | MULT:; UNSIGNED SIXTEEN BIT INTEGER MULTIPLY. 2 | ; ON ENTRANCE: MULTIPLIER IN DE. 3 | ; MULTIPLICAND IN HL. 4 | ; 5 | ; ON EXIT: RESULT IN HL. 6 | ; 7 | ; REGISTER USES: 8 | ; 9 | ; 10 | ; H HIGH ORDER PARTIAL RESULT 11 | ; L LOW ORDER PARTIAL RESULT 12 | ; D HIGH ORDER MULTIPLICAND 13 | ; E LOW ORDER MULTIPLICAND 14 | ; B COUNTER FOR NUMBER OF SHIFTS 15 | ; C HIGH ORDER BITS OF MULTIPLIER 16 | ; A LOW ORDER BITS OF MULTIPLIER 17 | ; 18 | LD B,16; NUMBER OF BITS- INITIALIZE 19 | LD C,D; MOVE MULTIPLIER 20 | LD A,E; 21 | LD X,Y ;SHOULD GET 'U' ERROR 22 | LOAD A,B ;SHOULD GET 'O' ERROR 23 | CP 'A' ;TEST 'X' FORMAT 24 | EX DE,HL; MOVE MULTIPLICAND 25 | LD HL,0; CLEAR PARTIAL RESULT 26 | EJECT ;TEST EJECT PROCESSING 27 | MLOOP: SRL C; SHIFT MULTIPLIER RIGHT 28 | RRA; LEAST SIGNIFICANT BIT IS IN CARRY 29 | JR NC,NOADD-$; IF NO CARRY SKIP THE ADD 30 | ADD HL,DE; ELSE ADD MULTIPLICAND TO PARTIAL RESULT 31 | NOADD: EX DE,HL; SHIFT MULTIPLICAND LEFT 32 | ADD HL,HL; BY MULTIPLYING IT BY TWO 33 | EX DE,HL; 34 | DJNZ MLOOP-$; REPEAT UNTIL NO MORE BITS 35 | RET; 36 | END; 37 |  -------------------------------------------------------------------------------- /releases/zsm20/Z80.DOC: -------------------------------------------------------------------------------- 1 | Z-80 Macro Library Documentation 2 | -------------------------------- 3 | 4 | I. 5 | The purpose of this library is to enable the assembly of the Z-80 6 | instruction set on a CP/M sytem using the CP/M MAC macro assembler. 7 | 8 | This library is invoked with the pseudo-op: 9 | 10 | " MACLIB Z80 " 11 | 12 | II. 13 | The following symbols and notations are used in the individual macro 14 | descriptions; 15 | 16 | r - Any of the 8 bit registers: A, B, C, D, E, H, L, or M 17 | rr - Any of the 16 bit register pairs: BC, DE, HL, or SP 18 | nn - 8 bit immediate data (0 through 255) 19 | d - 8 bit signed displacment (-128 through +127) 20 | nnnn - 16 bit address or immediate data (0 through 65535) 21 | b - bit number (0-7, 7 is most significant, 0 is least) 22 | addr - 16 bit address within PC+127 through PC-128 23 | m(zzz) - Memory at address "zzz" 24 | 25 | III. 26 | 27 | MACLIB ver. Zilog ver TDL ver 28 | -------------- ------------- ------------- 29 | 30 | LDX r,d LD r,(IX+d) MOV r,d(IX) 31 | Load register from indexed memory (with IX) 32 | 33 | LDY r,d LD r,(IY+d) MOV r,d(IY) 34 | Load register from indexed memory (with IY) 35 | 36 | STX r,d LD (IX+d),r MOV d(IX),r 37 | Store register to indexed memory (with IX) 38 | 39 | STY r,d LD (IY+d),r MOV d(IY),r 40 | Store register to indexed memory (with IY) 41 | 42 | MVIX nn,d LD (IX+d),nn MVI d(IX) 43 | Move immediate to indexed memory (with IX) 44 | 45 | MVIY nn,d LD (IY+d),nn MVI d(IY) 46 | Move immediate to indexed memory (with IY) 47 | 48 | LDAI LD A,I LDAI 49 | Move I to A 50 | 51 | LDAR LD A,R LDAR 52 | Move R to A 53 | 54 | STAI LD I,A STAI 55 | Move A to I 56 | 57 | STAR LD R,A STAR 58 | Move A to R 59 | 60 | LXIX nnnn LD IX,nnnn LXI IX,nnnn 61 | Load IX immediate (16 bits) 62 | 63 | LXIY nnnn LD IY,nnnn LXI IY,nnnn 64 | Load IY immediate (16 bits) 65 | 66 | LBCD nnnn LD BC,(nnnn) LBCD nnnn 67 | Load BC direct (from memory at nnnn) 68 | 69 | LDED nnnn LD DE,(nnnn) LDED nnnn 70 | Load DE direct 71 | 72 | LSPD nnnn LD SP,(nnnn) LSPD nnnn 73 | Load SP direct 74 | 75 | LIXD nnnn LD IX,(nnnn) LIXD nnnn 76 | Load IX direct 77 | 78 | LIYD nnnn LD IY,(nnnn) LIYD nnnn 79 | Load IY direct 80 | 81 | SBCD nnnn LD (nnnn),BC SBCD nnnn 82 | Store BC direct (to memory at nnnn) 83 | 84 | SDED nnnn LD (nnnn),DE SDED nnnn 85 | Store DE direct 86 | 87 | SSPD nnnn LD (nnnn),SP SSPD nnnn 88 | Store SP direct 89 | 90 | SIXD nnnn LD (nnnn),IX SIXD nnnn 91 | Store IX direct 92 | 93 | SIYD nnnn LD (nnnn),IY SIYD nnnn 94 | Store IY direct 95 | 96 | SPIX LD SP,IX SPIX 97 | Copy IX to the SP 98 | 99 | SPIY LD SP,IY SPIY 100 | Copy IY to the SP 101 | 102 | PUSHIX PUSH IX PUSH IX 103 | Push IX into the stack 104 | 105 | PUSHIY PUSH IY PUSH IY 106 | Push IY into the stack 107 | 108 | POPIX POP IX POP IX 109 | Pop IX from the stack 110 | 111 | POPIY POP IY POP IY 112 | Pop IY from the stack 113 | 114 | EXAF EX AF,AF' EXAF 115 | Exchange AF and the alternate, AF' 116 | 117 | EXX EXX EXX 118 | Exchange BC DE HL with BC' DE' HL' 119 | 120 | XTIX EX (SP),IX XTIX 121 | Exchange IX with the top of the stack 122 | 123 | XTIY EX (SP),IY XTIY 124 | Exchange IY with the top of the stack 125 | 126 | LDI LDI LDI 127 | Move m(HL) to m(DE), increment DE and HL, decrement BC 128 | 129 | LDIR LDIR LDIR 130 | Repeat LDI until BC = 0 131 | 132 | LDD LDD LDD 133 | Move m(HL) to m(DE), decrement HL, DE, and BC 134 | 135 | LDDR LDDR LDDR 136 | Repeat LDD until BC = 0 137 | 138 | CCI CPI CCI 139 | Compare A with m(HL), increment HL, decrement BC 140 | 141 | CCIR CPIR CCIR 142 | Repeat CCI until BC = 0 or A = m(HL) 143 | 144 | CCD CPD CCD 145 | Compare A with m(HL), decrement HL and BC 146 | 147 | CCDR CPDR CCDR 148 | Repeat CCD until BC = 0 or A = m(HL) 149 | 150 | ADDX d ADD (IX+d) ADD d(IX) 151 | Indexed add to A 152 | 153 | ADDY d ADD (IY+d) ADD d(IY) 154 | Indexed add to A 155 | 156 | ADCX d ADC (IX+d) ADC d(IX) 157 | Indexed add with carry 158 | 159 | ADCY d ADC (IY+d) ADC d(IY) 160 | Indexed add with carry 161 | 162 | SUBX d SUB (IX+d) SUB d(IX) 163 | Indexed subtract 164 | 165 | SUBY d SUB (IY+d) SUB d(IY) 166 | Indexed Subtract 167 | 168 | SBCX d SBC (IX+d) SBB d(IX) 169 | Indexed subtract with "borrow" 170 | 171 | SBCY d SBC (IY+d) SBB d(IY) 172 | Indexed subtract with borrow 173 | 174 | ANDX d AND (IX+d) ANA d(IX) 175 | Indexed logical and 176 | 177 | ANDY d AND (IY+d) ANA d(IY) 178 | Indexed logical and 179 | 180 | XORX d XOR (IX+d) XRA d(IX) 181 | Indexed logical exclusive or 182 | 183 | XORY d XOR (IY+d) XRA d(IY) 184 | Indexed logical exclusive or 185 | 186 | ORX d OR (IX+d) ORA d(IX) 187 | Indexed logical or 188 | 189 | ORY d OR (IY+d) ORA d(IY) 190 | Indexed logical exclusive or 191 | 192 | CMPX d CP (IX+d) CMP d(IX) 193 | Indexed compare 194 | 195 | CMPY d CP (IY+d) CMP d(IY) 196 | Index compare 197 | 198 | INRX d INC (IX+d) INR d(IX) 199 | Increment memory at m(IX+d) 200 | 201 | INRY d INC (IY+d) INR d(IY) 202 | Increment memory at m(IY+d) 203 | 204 | DCRX d INC (IX+d) INR d(IX) 205 | Decrement memory at m(IX+d) 206 | 207 | DCRY d DEC (IY+d) DCR d(IY) 208 | Decrement memory at m(IX+d) 209 | 210 | NEG NEG NEG 211 | Negate A (two's complement) 212 | 213 | IM0 IM0 IM0 214 | Set interrupt mode 0 215 | 216 | IM1 IM1 IM1 217 | Set interrupt mode 1 218 | 219 | IM2 IM2 IM2 220 | Set interrupt mode 2 221 | 222 | DADC rr ADC HL,rr DADC rr 223 | Add with carry rr to HL 224 | 225 | DSBC rr SBC HL,rr DSBC rr 226 | Subtract with "borrow" rr from HL 227 | 228 | DADX rr ADD IX,rr DADX rr 229 | Add rr to IX (rr may be BC, DE, SP, IX) 230 | 231 | DADY rr ADD IY,rr DADY rr 232 | Add rr to IY (rr may be BC, DE, SP, IY) 233 | 234 | INXIX INC IX INX IX 235 | Increment IX 236 | 237 | INXIY INC IY INX IY 238 | Increment IY 239 | 240 | DCXIX DEC IX DCX IX 241 | Decrement IX 242 | 243 | DCXIY DEC IY DCX IY 244 | Decrement IY 245 | 246 | BIT b,r BIT b,r BIT b,r 247 | Test bit b in register r 248 | 249 | SETB b,r SET b,r SET b,r 250 | Set bit b in register r 251 | 252 | RES b,r RES b,r RES b,r 253 | Reset bit b in register r 254 | 255 | BITX b,d BIT b,(IX+d) BIT b,d(IX) 256 | Test bit b in memory at m(IX+d) 257 | 258 | BITY b,d BIT b,(IY+d) BIT b,d(IY) 259 | Test bit b in memory at m(IY+d) 260 | 261 | SETX b,d SET b,(IX+d) SET b,d(IX) 262 | Set bit b in memory at m(IX+d) 263 | 264 | SETY b,d SET b,(IY+d) SET b,d(IY) 265 | Set bit b in memory at m(IY+d) 266 | 267 | RESX b,d RES b,(IX+d) RES b,d(IX) 268 | Reset bit b in memory at m(IX+d) 269 | 270 | RESY b,d RES b,(IY+d) RES b,d(IY) 271 | Reset bit b in memory at m(IY+d) 272 | 273 | JR addr JR addr-$ JMPR addr 274 | Jump relative unconditional 275 | 276 | JRC addr JR C,addr-$ JRC addr 277 | Jump relative if Carry indicator true 278 | 279 | JRNC addr JR NC,addr-$ JRNC addr 280 | Jump relative if carry indicator false 281 | 282 | JRZ addr JR Z,addr-$ JRC addr 283 | Jump relative if Zero indicator true 284 | 285 | JRNZ addr JR NZ,addr-$ JRNZ addr 286 | Jump relative if Zero indicator false 287 | 288 | DJNZ addr DJNZ addr-$ DJNZ addr 289 | Decrement B, jump relative if non-zero 290 | 291 | PCIX JMP (IX) PCIX 292 | Jump to address in IX ie, Load PC from IX 293 | 294 | PCIY JMP (IY) PCIY 295 | Jump to address in IY 296 | 297 | RETI RETI RETI 298 | Return from interrupt 299 | 300 | RETN RETN RETN 301 | Return from non-maskable interrupt 302 | 303 | INP r IN r,(C) INP r 304 | Input from port C to register r 305 | 306 | OUTP r OUT (C),r OUTP r 307 | Output from register r to port (C) 308 | 309 | INI INI INI 310 | Input from port (C) to m(HL), increment HL, decrement b 311 | 312 | INIR INIR INIR 313 | Input from port (C) to m(HL), increment HL, decrement B, repeat if B <> 0 314 | 315 | OUTI OTI OUTI 316 | Output from m(HL) to port (C), increment HL, decrement B 317 | 318 | OUTIR OTIR OUTIR 319 | Repeat OUTI until B = 0 320 | 321 | IND IND IND 322 | Input from port (C) to m(HL), decrement HL & B 323 | 324 | INDR INDR INDR 325 | Repeat IND until B = 0 326 | 327 | OUTD OTD OUTD 328 | Output from m(HL) to port (C), decrement HL & B 329 | 330 | OUTDR OTDR OUTDR 331 | Repeat OUTD until B = 0 332 | 333 | RLCR r RLC r RLCR r 334 | Rotate left circular register 335 | 336 | RLCX d RLC (IX+d) RLCR d(IX) 337 | Rotate left circular indexed memory 338 | 339 | RLCY d RLC (IY+d) RLCR d(IY) 340 | Rotate left circular indexed memory 341 | 342 | RALR r RL r RALR r 343 | Rotate left arithmetic register 344 | 345 | RALX d RL (IX+d) RALR d(IX) 346 | Rotate left arithmetic indexed memory 347 | 348 | RALY d RL (IY+d) RALR d(IY) 349 | Rotate left arithmetic indexed memory 350 | 351 | RRCR r RRC r RRCR r 352 | Rotate right circular register 353 | 354 | RRCX d RRC (IX+d) RRCR d(IX) 355 | Rotate right circular indexed 356 | 357 | RRCY d RRC (IY+d) RRCR d(IY) 358 | Rotate right circular indexed 359 | 360 | RARR r RR r RARR r 361 | Rotate right arithmetic register 362 | 363 | RARX d RR (IX+d) RARR d(IX) 364 | Rotate right arithmetic indexed memory 365 | 366 | RARY d RR (IY+d) RARR d(IY) 367 | Rotate right arithmetic indexed memory 368 | 369 | SLAR r SLA r SLAR r 370 | Shift left register 371 | 372 | SLAX d SLA (IX+d) SLAR d(IX) 373 | Shift left indexed memory 374 | 375 | SLAY d SLA (IY+d) SLAR d(IY) 376 | Shift left indexed memory 377 | 378 | SRAR r SRA r SRAR r 379 | Shift right arithmetic register 380 | 381 | SRAX d SRA (IX+d) SRAR d(IX) 382 | Shift right arithmetic indexed memory 383 | 384 | SRAY d SRA (IY+d) SRAR d(IY) 385 | Shift right arithmetic indexed memory 386 | 387 | SRLR r SRL r SRLR r 388 | Shift right logical register 389 | 390 | SRLX d SRL (IX+d) SRLR d(IX) 391 | Shift right logical indexed memory 392 | 393 | SRLY d SRL (IY+d) SRLR d(IY) 394 | Shift right logical indexed memory 395 | 396 | RLD RLD RLD 397 | Rotate left digit 398 | 399 | RRD RRD RRD 400 | Rotate right digit 401 | 402 |  -------------------------------------------------------------------------------- /releases/zsm20/Z80.LIB: -------------------------------------------------------------------------------- 1 | ; @CHK MACRO USED FOR CHECKING 8 BIT DISPLACMENTS 2 | ; 3 | @CHK MACRO ?DD ;; USED FOR CHECKING RANGE OF 8-BIT DISP.S 4 | IF (?DD GT 7FH) AND (?DD LT 0FF80H) 5 | 'DISPLACEMENT RANGE ERROR - Z80 LIB' 6 | ENDIF 7 | ENDM 8 | LDX MACRO ?R,?D 9 | @CHK ?D 10 | DB 0DDH,?R*8+46H,?D 11 | ENDM 12 | LDY MACRO ?R,?D 13 | @CHK ?D 14 | DB 0FDH,?R*8+46H,?D 15 | ENDM 16 | STX MACRO ?R,?D 17 | @CHK ?D 18 | DB 0DDH,70H+?R,?D 19 | ENDM 20 | STY MACRO ?R,?D 21 | @CHK ?D 22 | DB 0FDH,70H+?R,?D 23 | ENDM 24 | MVIX MACRO ?N,?D 25 | @CHK ?D 26 | DB 0DDH,36H,?D,?N 27 | ENDM 28 | MVIY MACRO ?N,?D 29 | @CHK ?D 30 | DB 0FDH,36H,?D,?N 31 | ENDM 32 | LDAI MACRO 33 | DB 0EDH,57H 34 | ENDM 35 | LDAR MACRO 36 | DB 0EDH,5FH 37 | ENDM 38 | STAI MACRO 39 | DB 0EDH,47H 40 | ENDM 41 | STAR MACRO 42 | DB 0EDH,4FH 43 | ENDM 44 | 45 | LXIX MACRO ?NNNN 46 | DB 0DDH,21H 47 | DW ?NNNN 48 | ENDM 49 | LXIY MACRO ?NNNN 50 | DB 0FDH,21H 51 | DW ?NNNN 52 | ENDM 53 | LDED MACRO ?NNNN 54 | DB 0EDH,5BH 55 | DW ?NNNN 56 | ENDM 57 | LBCD MACRO ?NNNN 58 | DB 0EDH,4BH 59 | DW ?NNNN 60 | ENDM 61 | LSPD MACRO ?NNNN 62 | DB 0EDH,07BH 63 | DW ?NNNN 64 | ENDM 65 | LIXD MACRO ?NNNN 66 | DB 0DDH,2AH 67 | DW ?NNNN 68 | ENDM 69 | LIYD MACRO ?NNNN 70 | DB 0FDH,2AH 71 | DW ?NNNN 72 | ENDM 73 | SBCD MACRO ?NNNN 74 | DB 0EDH,43H 75 | DW ?NNNN 76 | ENDM 77 | SDED MACRO ?NNNN 78 | DB 0EDH,53H 79 | DW ?NNNN 80 | ENDM 81 | SSPD MACRO ?NNNN 82 | DB 0EDH,73H 83 | DW ?NNNN 84 | ENDM 85 | SIXD MACRO ?NNNN 86 | DB 0DDH,22H 87 | DW ?NNNN 88 | ENDM 89 | SIYD MACRO ?NNNN 90 | DB 0FDH,22H 91 | DW ?NNNN 92 | ENDM 93 | SPIX MACRO 94 | DB 0DDH,0F9H 95 | ENDM 96 | SPIY MACRO 97 | DB 0FDH,0F9H 98 | ENDM 99 | PUSHIX MACRO 100 | DB 0DDH,0E5H 101 | ENDM 102 | PUSHIY MACRO 103 | DB 0FDH,0E5H 104 | ENDM 105 | POPIX MACRO 106 | DB 0DDH,0E1H 107 | ENDM 108 | POPIY MACRO 109 | DB 0FDH,0E1H 110 | ENDM 111 | EXAF MACRO 112 | DB 08H 113 | ENDM 114 | EXX MACRO 115 | DB 0D9H 116 | ENDM 117 | XTIX MACRO 118 | DB 0DDH,0E3H 119 | ENDM 120 | XTIY MACRO 121 | DB 0FDH,0E3H 122 | ENDM 123 | 124 | LDI MACRO 125 | DB 0EDH,0A0H 126 | ENDM 127 | LDIR MACRO 128 | DB 0EDH,0B0H 129 | ENDM 130 | LDD MACRO 131 | DB 0EDH,0A8H 132 | ENDM 133 | LDDR MACRO 134 | DB 0EDH,0B8H 135 | ENDM 136 | CCI MACRO 137 | DB 0EDH,0A1H 138 | ENDM 139 | CCIR MACRO 140 | DB 0EDH,0B1H 141 | ENDM 142 | CCD MACRO 143 | DB 0EDH,0A9H 144 | ENDM 145 | CCDR MACRO 146 | DB 0EDH,0B9H 147 | ENDM 148 | 149 | ADDX MACRO ?D 150 | @CHK ?D 151 | DB 0DDH,86H,?D 152 | ENDM 153 | ADDY MACRO ?D 154 | @CHK ?D 155 | DB 0FDH,86H,?D 156 | ENDM 157 | ADCX MACRO ?D 158 | @CHK ?D 159 | DB 0DDH,8EH,?D 160 | ENDM 161 | ADCY MACRO ?D 162 | @CHK ?D 163 | DB 0FDH,8EH,?D 164 | ENDM 165 | SUBX MACRO ?D 166 | @CHK ?D 167 | DB 0DDH,96H,?D 168 | ENDM 169 | SUBY MACRO ?D 170 | @CHK ?D 171 | DB 0FDH,96H,?D 172 | ENDM 173 | SBCX MACRO ?D 174 | @CHK ?D 175 | DB 0DDH,9EH,?D 176 | ENDM 177 | SBCY MACRO ?D 178 | @CHK ?D 179 | DB 0FDH,9EH,?D 180 | ENDM 181 | ANDX MACRO ?D 182 | @CHK ?D 183 | DB 0DDH,0A6H,?D 184 | ENDM 185 | ANDY MACRO ?D 186 | @CHK ?D 187 | DB 0FDH,0A6H,?D 188 | ENDM 189 | XORX MACRO ?D 190 | @CHK ?D 191 | DB 0DDH,0AEH,?D 192 | ENDM 193 | XORY MACRO ?D 194 | @CHK ?D 195 | DB 0FDH,0AEH,?D 196 | ENDM 197 | ORX MACRO ?D 198 | @CHK ?D 199 | DB 0DDH,0B6H,?D 200 | ENDM 201 | ORY MACRO ?D 202 | @CHK ?D 203 | DB 0FDH,0B6H,?D 204 | ENDM 205 | CMPX MACRO ?D 206 | @CHK ?D 207 | DB 0DDH,0BEH,?D 208 | ENDM 209 | CMPY MACRO ?D 210 | @CHK ?D 211 | DB 0FDH,0BEH,?D 212 | ENDM 213 | INRX MACRO ?D 214 | @CHK ?D 215 | DB 0DDH,34H,?D 216 | ENDM 217 | INRY MACRO ?D 218 | @CHK ?D 219 | DB 0FDH,34H,?D 220 | ENDM 221 | DCRX MACRO ?D 222 | @CHK ?D 223 | DB 0DDH,035H,?D 224 | ENDM 225 | DCRY MACRO ?D 226 | @CHK ?D 227 | DB 0FDH,35H,?D 228 | ENDM 229 | 230 | NEG MACRO 231 | DB 0EDH,44H 232 | ENDM 233 | IM0 MACRO 234 | DB 0EDH,46H 235 | ENDM 236 | IM1 MACRO 237 | DB 0EDH,56H 238 | ENDM 239 | IM2 MACRO 240 | DB 0EDH,5EH 241 | ENDM 242 | 243 | 244 | BC EQU 0 245 | DE EQU 2 246 | HL EQU 4 247 | IX EQU 4 248 | IY EQU 4 249 | DADC MACRO ?R 250 | DB 0EDH,?R*8+4AH 251 | ENDM 252 | DSBC MACRO ?R 253 | DB 0EDH,?R*8+42H 254 | ENDM 255 | DADX MACRO ?R 256 | DB 0DDH,?R*8+09H 257 | ENDM 258 | DADY MACRO ?R 259 | DB 0FDH,?R*8+09H 260 | ENDM 261 | INXIX MACRO 262 | DB 0DDH,23H 263 | ENDM 264 | INXIY MACRO 265 | DB 0FDH,23H 266 | ENDM 267 | DCXIX MACRO 268 | DB 0DDH,2BH 269 | ENDM 270 | DCXIY MACRO 271 | DB 0FDH,2BH 272 | ENDM 273 | 274 | BIT MACRO ?N,?R 275 | DB 0CBH,?N*8+?R+40H 276 | ENDM 277 | SETB MACRO ?N,?R 278 | DB 0CBH,?N*8+?R+0C0H 279 | ENDM 280 | RES MACRO ?N,?R 281 | DB 0CBH,?N*8+?R+80H 282 | ENDM 283 | 284 | BITX MACRO ?N,?D 285 | @CHK ?D 286 | DB 0DDH,0CBH,?D,?N*8+46H 287 | ENDM 288 | BITY MACRO ?N,?D 289 | @CHK ?D 290 | DB 0FDH,0CBH,?D,?N*8+46H 291 | ENDM 292 | SETX MACRO ?N,?D 293 | @CHK ?D 294 | DB 0DDH,0CBH,?D,?N*8+0C6H 295 | ENDM 296 | SETY MACRO ?N,?D 297 | @CHK ?D 298 | DB 0FDH,0CBH,?D,?N*8+0C6H 299 | ENDM 300 | RESX MACRO ?N,?D 301 | @CHK ?D 302 | DB 0DDH,0CBH,?D,?N*8+86H 303 | ENDM 304 | RESY MACRO ?N,?D 305 | @CHK ?D 306 | DB 0FDH,0CBH,?D,?N*8+86H 307 | ENDM 308 | 309 | JR MACRO ?N 310 | DB 18H,?N-$-1 311 | ENDM 312 | JRC MACRO ?N 313 | DB 38H,?N-$-1 314 | ENDM 315 | JRNC MACRO ?N 316 | DB 30H,?N-$-1 317 | ENDM 318 | JRZ MACRO ?N 319 | DB 28H,?N-$-1 320 | ENDM 321 | JRNZ MACRO ?N 322 | DB 20H,?N-$-1 323 | ENDM 324 | DJNZ MACRO ?N 325 | DB 10H,?N-$-1 326 | ENDM 327 | 328 | PCIX MACRO 329 | DB 0DDH,0E9H 330 | ENDM 331 | PCIY MACRO 332 | DB 0FDH,0E9H 333 | ENDM 334 | 335 | RETI MACRO 336 | DB 0EDH,4DH 337 | ENDM 338 | RETN MACRO 339 | DB 0EDH,45H 340 | ENDM 341 | 342 | INP MACRO ?R 343 | DB 0EDH,?R*8+40H 344 | ENDM 345 | OUTP MACRO ?R 346 | DB 0EDH,?R*8+41H 347 | ENDM 348 | INI MACRO 349 | DB 0EDH,0A2H 350 | ENDM 351 | INIR MACRO 352 | DB 0EDH,0B2H 353 | ENDM 354 | IND MACRO 355 | DB 0EDH,0AAH 356 | ENDM 357 | INDR MACRO 358 | DB 0EDH,0BAH 359 | ENDM 360 | OUTI MACRO 361 | DB 0EDH,0A3H 362 | ENDM 363 | OUTIR MACRO 364 | DB 0EDH,0B3H 365 | ENDM 366 | OUTD MACRO 367 | DB 0EDH,0ABH 368 | ENDM 369 | OUTDR MACRO 370 | DB 0EDH,0BBH 371 | ENDM 372 | 373 | 374 | RLCR MACRO ?R 375 | DB 0CBH, 00H + ?R 376 | ENDM 377 | RLCX MACRO ?D 378 | @CHK ?D 379 | DB 0DDH, 0CBH, ?D, 06H 380 | ENDM 381 | RLCY MACRO ?D 382 | @CHK ?D 383 | DB 0FDH, 0CBH, ?D, 06H 384 | ENDM 385 | RALR MACRO ?R 386 | DB 0CBH, 10H+?R 387 | ENDM 388 | RALX MACRO ?D 389 | @CHK ?D 390 | DB 0DDH, 0CBH, ?D, 16H 391 | ENDM 392 | RALY MACRO ?D 393 | @CHK ?D 394 | DB 0FDH, 0CBH, ?D, 16H 395 | ENDM 396 | RRCR MACRO ?R 397 | DB 0CBH, 08H + ?R 398 | ENDM 399 | RRCX MACRO ?D 400 | @CHK ?D 401 | DB 0DDH, 0CBH, ?D, 0EH 402 | ENDM 403 | RRCY MACRO ?D 404 | @CHK ?D 405 | DB 0FDH, 0CBH, ?D, 0EH 406 | ENDM 407 | RARR MACRO ?R 408 | DB 0CBH, 18H + ?R 409 | ENDM 410 | RARX MACRO ?D 411 | @CHK ?D 412 | DB 0DDH, 0CBH, ?D, 1EH 413 | ENDM 414 | RARY MACRO ?D 415 | @CHK ?D 416 | DB 0FDH, 0CBH, ?D, 1EH 417 | ENDM 418 | SLAR MACRO ?R 419 | DB 0CBH, 20H + ?R 420 | ENDM 421 | SLAX MACRO ?D 422 | @CHK ?D 423 | DB 0DDH, 0CBH, ?D, 26H 424 | ENDM 425 | SLAY MACRO ?D 426 | @CHK ?D 427 | DB 0FDH, 0CBH, ?D, 26H 428 | ENDM 429 | SRAR MACRO ?R 430 | DB 0CBH, 28H+?R 431 | ENDM 432 | SRAX MACRO ?D 433 | @CHK ?D 434 | DB 0DDH, 0CBH, ?D, 2EH 435 | ENDM 436 | SRAY MACRO ?D 437 | @CHK ?D 438 | DB 0FDH, 0CBH, ?D, 2EH 439 | ENDM 440 | SRLR MACRO ?R 441 | DB 0CBH, 38H + ?R 442 | ENDM 443 | SRLX MACRO ?D 444 | @CHK ?D 445 | DB 0DDH, 0CBH, ?D, 3EH 446 | ENDM 447 | SRLY MACRO ?D 448 | @CHK ?D 449 | DB 0FDH, 0CBH, ?D, 3EH 450 | ENDM 451 | RLD MACRO 452 | DB 0EDH, 6FH 453 | ENDM 454 | RRD MACRO 455 | DB 0EDH, 67H 456 | ENDM 457 |  -------------------------------------------------------------------------------- /releases/zsm20/Z80ASM.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MiguelVis/zsm/00da4e7d1815dfadd9a7b74b051b3b56afdc7006/releases/zsm20/Z80ASM.COM -------------------------------------------------------------------------------- /releases/zsm20/Z80DOC.DOC: -------------------------------------------------------------------------------- 1 | 2 | 3 | Z 4 | 8 5 | 0 6 | A 7 | S 8 | M 9 | 10 | 11 | ZILOG/MOSTEK 12 | 13 | Z80-CPU 14 | 15 | 16 | ASSEMBLY 17 | LANGUAGE 18 | PROCESSOR 19 | 20 | 21 | (C) COPYRIGHT 1977 LCS 22 | ALL RIGHTS RESERVED 23 | 24 | 25 | LATEST REVISION: 21-JULY-1977 26 | 27 | 28 | Z 8 0 A S M 29 | 30 | Z80ASM IS AN ASSEMBLER FOR THE ZILOG/MOSTEK Z80-CPU MICROPROCESSOR. 31 | 32 | IT IS DESIGNED TO RUN UNDER THE CP/M OPERATING SYSTEM FROM DIGITAL RESEARCH. 33 | 34 | CP/M WILL RUN ON EITHER AN 8080A SYSTEM OR A Z80 SYSTEM. Z80ASM WILL RUN 35 | 36 | IN THE CP/M MINIMUM (16K) SYSTEM BUT WILL UTILIZE MORE MEMORY FOR SYMBOL 37 | 38 | TABLE STORAGE IN LARGER (UP TO 64K) CP/M SYSTEMS. 39 | 40 | Z80ASM READS A SOURCE (ASM) FILE PRODUCED BY THE CP/M 'ED' TEXT EDITOR 41 | 42 | PROGRAM AND PRODUCES AN OPTIONAL LISTING (ON THE LST: DEVICE) AND AN OPTIONAL 43 | 44 | OBJECT CODE (HEX) FILE IN INTEL FORMAT HEX. THE 'HEX' FILE CAN BE LOADED 45 | 46 | FOR EXECUTION USING 'DDT' OR 'LOAD' COMMANDS OF CP/M OR IT CAN BE PUNCHED 47 | 48 | ON PAPER TAPE USING THE 'PIP' PROGRAM. 49 | 50 | INPUT STATEMENTS ARE FREE FORMAT (I.E. NOT COLUMN ORIENTED). BETWEEN 51 | 52 | FIELDS ANY NUMBER OF BLANK OR TAB CHARACTERS MAY BE PRESENT BUT WITHIN A FIELD 53 | 54 | THERE MAY BE NO BLANK OR TAB CHARACTERS. HOWEVER, STATEMENTS LABELS MUST BE 55 | 56 | IN THE FIRST POSITION OF THE LINE. STATEMENT LABELS MAY HAVE A COLON FOLLOWING 57 | 58 | THEM BUT THE COLON IS NOT REQUIRED. COMMENTS ARE PRECEEDED BY A SEMICOLON 59 | 60 | AND MAY APPEAR BY THEMSELVES OR FOLLOWING ALL OF THE FIELDS ON A SOURCE LINE. 61 | 62 | 63 | ALL THE ZILOG/MOSTEK MNEMONICS ARE SUPPORTED WITH THE FOLLOWING 64 | 65 | EXCEPTIONS: 66 | 67 | 1. THE Z80CPU TECHNICAL MANUAL HAS CONFLICTING INFORMATION REGARDING 68 | THE SYNTAX OF THE RLC,RL,RRC AND RR INSTRUCTIONS WHEN THE A 69 | REGISTER IS USED AS THE OPERAND. ON PAGE 50 THE FORMS 70 | 'RLCA','RLA','RRCA','RRA' ARE USED WHILE ON PAGE 68 THE FORM 71 | 'RR A' IS SHOWN. Z80ASM WILL SUPPORT ONLY THE 'RRA', ETC. FORM. 72 | 73 | 2. THE Z80CPU MANUAL DOES NOT DESCRIBE THE PSEUDO OPERATORS AVAILABLE 74 | EXCEPT THAT 'EQU' AND 'DEFS' ARE USED ON PAGE 67 IN THE SAMPLE 75 | PROGRAM. THE LIST BELOW DESCRIBES THE PSEUDO OPERATORS AVAILABLE 76 | IN Z80ASM AND THEIR ARGUMENT FORMATS: 77 | 78 |