├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── README.md ├── TODO ├── autogen.sh ├── configure.ac ├── doc └── asm8080_um.txt ├── mac └── Makefile ├── src ├── Makefile.am ├── Makefile.in ├── asm_dir.c ├── asm_dir.h ├── err_code.h ├── exp_parser.c ├── exp_parser.h ├── main.c ├── main.h ├── msg.c ├── msg.h ├── opcode.c ├── opcode.h ├── project.h ├── util.c ├── util.h └── war_code.h ├── test ├── als8.asm ├── b_tbl.asm ├── div.asm ├── dsub.asm ├── jos.asm ├── madd.asm ├── main.asm ├── mult.asm ├── test.asm ├── test1.asm ├── test_comment.asm ├── test_db_1.asm ├── test_dw_1.asm ├── test_ee.asm ├── test_ep_1.asm ├── test_ep_2.asm ├── test_ep_3.asm ├── test_ep_4.asm ├── test_ep_5.asm ├── test_equ.asm ├── test_high.asm ├── test_if.asm ├── test_include.asm ├── test_jmp.asm ├── test_listing.asm ├── test_listing2.asm ├── test_macro.asm ├── test_not.asm ├── test_opcode_in.asm ├── test_operator.asm ├── test_reg.asm ├── test_reg1.asm ├── test_sign.asm └── test_solace.asm └── windows ├── Makefile └── strncasecmp.c /.gitignore: -------------------------------------------------------------------------------- 1 | go-git.cmd 2 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Jay Cotton lbmgmusic@gmail.com 2 | Claude Sylvain csylvain@electro-technica.com 3 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Its an MIT license. 2 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 4/23/2017 Jos De Laender provided a bug fix for comments after CPI instruction. 2 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 5 | 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 6 | 7 | Copying and distribution of this file, with or without modification, 8 | are permitted in any medium without royalty provided the copyright 9 | notice and this notice are preserved. This file is offered as-is, 10 | without warranty of any kind. 11 | 12 | Basic Installation 13 | ================== 14 | 15 | Briefly, the shell commands `./configure; make; make install' should 16 | configure, build, and install this package. The following 17 | more-detailed instructions are generic; see the `README' file for 18 | instructions specific to this package. Some packages provide this 19 | `INSTALL' file but do not implement all of the features documented 20 | below. The lack of an optional feature in a given package is not 21 | necessarily a bug. More recommendations for GNU packages can be found 22 | in *note Makefile Conventions: (standards)Makefile Conventions. 23 | 24 | The `configure' shell script attempts to guess correct values for 25 | various system-dependent variables used during compilation. It uses 26 | those values to create a `Makefile' in each directory of the package. 27 | It may also create one or more `.h' files containing system-dependent 28 | definitions. Finally, it creates a shell script `config.status' that 29 | you can run in the future to recreate the current configuration, and a 30 | file `config.log' containing compiler output (useful mainly for 31 | debugging `configure'). 32 | 33 | It can also use an optional file (typically called `config.cache' 34 | and enabled with `--cache-file=config.cache' or simply `-C') that saves 35 | the results of its tests to speed up reconfiguring. Caching is 36 | disabled by default to prevent problems with accidental use of stale 37 | cache files. 38 | 39 | If you need to do unusual things to compile the package, please try 40 | to figure out how `configure' could check whether to do them, and mail 41 | diffs or instructions to the address given in the `README' so they can 42 | be considered for the next release. If you are using the cache, and at 43 | some point `config.cache' contains results you don't want to keep, you 44 | may remove or edit it. 45 | 46 | The file `configure.ac' (or `configure.in') is used to create 47 | `configure' by a program called `autoconf'. You need `configure.ac' if 48 | you want to change it or regenerate `configure' using a newer version 49 | of `autoconf'. 50 | 51 | The simplest way to compile this package is: 52 | 53 | 1. `cd' to the directory containing the package's source code and type 54 | `./configure' to configure the package for your system. 55 | 56 | Running `configure' might take a while. While running, it prints 57 | some messages telling which features it is checking for. 58 | 59 | 2. Type `make' to compile the package. 60 | 61 | 3. Optionally, type `make check' to run any self-tests that come with 62 | the package, generally using the just-built uninstalled binaries. 63 | 64 | 4. Type `make install' to install the programs and any data files and 65 | documentation. When installing into a prefix owned by root, it is 66 | recommended that the package be configured and built as a regular 67 | user, and only the `make install' phase executed with root 68 | privileges. 69 | 70 | 5. Optionally, type `make installcheck' to repeat any self-tests, but 71 | this time using the binaries in their final installed location. 72 | This target does not install anything. Running this target as a 73 | regular user, particularly if the prior `make install' required 74 | root privileges, verifies that the installation completed 75 | correctly. 76 | 77 | 6. You can remove the program binaries and object files from the 78 | source code directory by typing `make clean'. To also remove the 79 | files that `configure' created (so you can compile the package for 80 | a different kind of computer), type `make distclean'. There is 81 | also a `make maintainer-clean' target, but that is intended mainly 82 | for the package's developers. If you use it, you may have to get 83 | all sorts of other programs in order to regenerate files that came 84 | with the distribution. 85 | 86 | 7. Often, you can also type `make uninstall' to remove the installed 87 | files again. In practice, not all packages have tested that 88 | uninstallation works correctly, even though it is required by the 89 | GNU Coding Standards. 90 | 91 | 8. Some packages, particularly those that use Automake, provide `make 92 | distcheck', which can by used by developers to test that all other 93 | targets like `make install' and `make uninstall' work correctly. 94 | This target is generally not run by end users. 95 | 96 | Compilers and Options 97 | ===================== 98 | 99 | Some systems require unusual options for compilation or linking that 100 | the `configure' script does not know about. Run `./configure --help' 101 | for details on some of the pertinent environment variables. 102 | 103 | You can give `configure' initial values for configuration parameters 104 | by setting variables in the command line or in the environment. Here 105 | is an example: 106 | 107 | ./configure CC=c99 CFLAGS=-g LIBS=-lposix 108 | 109 | *Note Defining Variables::, for more details. 110 | 111 | Compiling For Multiple Architectures 112 | ==================================== 113 | 114 | You can compile the package for more than one kind of computer at the 115 | same time, by placing the object files for each architecture in their 116 | own directory. To do this, you can use GNU `make'. `cd' to the 117 | directory where you want the object files and executables to go and run 118 | the `configure' script. `configure' automatically checks for the 119 | source code in the directory that `configure' is in and in `..'. This 120 | is known as a "VPATH" build. 121 | 122 | With a non-GNU `make', it is safer to compile the package for one 123 | architecture at a time in the source code directory. After you have 124 | installed the package for one architecture, use `make distclean' before 125 | reconfiguring for another architecture. 126 | 127 | On MacOS X 10.5 and later systems, you can create libraries and 128 | executables that work on multiple system types--known as "fat" or 129 | "universal" binaries--by specifying multiple `-arch' options to the 130 | compiler but only a single `-arch' option to the preprocessor. Like 131 | this: 132 | 133 | ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 134 | CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 135 | CPP="gcc -E" CXXCPP="g++ -E" 136 | 137 | This is not guaranteed to produce working output in all cases, you 138 | may have to build one architecture at a time and combine the results 139 | using the `lipo' tool if you have problems. 140 | 141 | Installation Names 142 | ================== 143 | 144 | By default, `make install' installs the package's commands under 145 | `/usr/local/bin', include files under `/usr/local/include', etc. You 146 | can specify an installation prefix other than `/usr/local' by giving 147 | `configure' the option `--prefix=PREFIX', where PREFIX must be an 148 | absolute file name. 149 | 150 | You can specify separate installation prefixes for 151 | architecture-specific files and architecture-independent files. If you 152 | pass the option `--exec-prefix=PREFIX' to `configure', the package uses 153 | PREFIX as the prefix for installing programs and libraries. 154 | Documentation and other data files still use the regular prefix. 155 | 156 | In addition, if you use an unusual directory layout you can give 157 | options like `--bindir=DIR' to specify different values for particular 158 | kinds of files. Run `configure --help' for a list of the directories 159 | you can set and what kinds of files go in them. In general, the 160 | default for these options is expressed in terms of `${prefix}', so that 161 | specifying just `--prefix' will affect all of the other directory 162 | specifications that were not explicitly provided. 163 | 164 | The most portable way to affect installation locations is to pass the 165 | correct locations to `configure'; however, many packages provide one or 166 | both of the following shortcuts of passing variable assignments to the 167 | `make install' command line to change installation locations without 168 | having to reconfigure or recompile. 169 | 170 | The first method involves providing an override variable for each 171 | affected directory. For example, `make install 172 | prefix=/alternate/directory' will choose an alternate location for all 173 | directory configuration variables that were expressed in terms of 174 | `${prefix}'. Any directories that were specified during `configure', 175 | but not in terms of `${prefix}', must each be overridden at install 176 | time for the entire installation to be relocated. The approach of 177 | makefile variable overrides for each directory variable is required by 178 | the GNU Coding Standards, and ideally causes no recompilation. 179 | However, some platforms have known limitations with the semantics of 180 | shared libraries that end up requiring recompilation when using this 181 | method, particularly noticeable in packages that use GNU Libtool. 182 | 183 | The second method involves providing the `DESTDIR' variable. For 184 | example, `make install DESTDIR=/alternate/directory' will prepend 185 | `/alternate/directory' before all installation names. The approach of 186 | `DESTDIR' overrides is not required by the GNU Coding Standards, and 187 | does not work on platforms that have drive letters. On the other hand, 188 | it does better at avoiding recompilation issues, and works well even 189 | when some directory options were not specified in terms of `${prefix}' 190 | at `configure' time. 191 | 192 | Optional Features 193 | ================= 194 | 195 | If the package supports it, you can cause programs to be installed 196 | with an extra prefix or suffix on their names by giving `configure' the 197 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 198 | 199 | Some packages pay attention to `--enable-FEATURE' options to 200 | `configure', where FEATURE indicates an optional part of the package. 201 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 202 | is something like `gnu-as' or `x' (for the X Window System). The 203 | `README' should mention any `--enable-' and `--with-' options that the 204 | package recognizes. 205 | 206 | For packages that use the X Window System, `configure' can usually 207 | find the X include and library files automatically, but if it doesn't, 208 | you can use the `configure' options `--x-includes=DIR' and 209 | `--x-libraries=DIR' to specify their locations. 210 | 211 | Some packages offer the ability to configure how verbose the 212 | execution of `make' will be. For these packages, running `./configure 213 | --enable-silent-rules' sets the default to minimal output, which can be 214 | overridden with `make V=1'; while running `./configure 215 | --disable-silent-rules' sets the default to verbose, which can be 216 | overridden with `make V=0'. 217 | 218 | Particular systems 219 | ================== 220 | 221 | On HP-UX, the default C compiler is not ANSI C compatible. If GNU 222 | CC is not installed, it is recommended to use the following options in 223 | order to use an ANSI C compiler: 224 | 225 | ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" 226 | 227 | and if that doesn't work, install pre-built binaries of GCC for HP-UX. 228 | 229 | On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot 230 | parse its `' header file. The option `-nodtk' can be used as 231 | a workaround. If GNU CC is not installed, it is therefore recommended 232 | to try 233 | 234 | ./configure CC="cc" 235 | 236 | and if that doesn't work, try 237 | 238 | ./configure CC="cc -nodtk" 239 | 240 | On Solaris, don't put `/usr/ucb' early in your `PATH'. This 241 | directory contains several dysfunctional programs; working variants of 242 | these programs are available in `/usr/bin'. So, if you need `/usr/ucb' 243 | in your `PATH', put it _after_ `/usr/bin'. 244 | 245 | On Haiku, software installed for all users goes in `/boot/common', 246 | not `/usr/local'. It is recommended to use the following options: 247 | 248 | ./configure --prefix=/boot/common 249 | 250 | Specifying the System Type 251 | ========================== 252 | 253 | There may be some features `configure' cannot figure out 254 | automatically, but needs to determine by the type of machine the package 255 | will run on. Usually, assuming the package is built to be run on the 256 | _same_ architectures, `configure' can figure that out, but if it prints 257 | a message saying it cannot guess the machine type, give it the 258 | `--build=TYPE' option. TYPE can either be a short name for the system 259 | type, such as `sun4', or a canonical name which has the form: 260 | 261 | CPU-COMPANY-SYSTEM 262 | 263 | where SYSTEM can have one of these forms: 264 | 265 | OS 266 | KERNEL-OS 267 | 268 | See the file `config.sub' for the possible values of each field. If 269 | `config.sub' isn't included in this package, then this package doesn't 270 | need to know the machine type. 271 | 272 | If you are _building_ compiler tools for cross-compiling, you should 273 | use the option `--target=TYPE' to select the type of system they will 274 | produce code for. 275 | 276 | If you want to _use_ a cross compiler, that generates code for a 277 | platform different from the build platform, you should specify the 278 | "host" platform (i.e., that on which the generated programs will 279 | eventually be run) with `--host=TYPE'. 280 | 281 | Sharing Defaults 282 | ================ 283 | 284 | If you want to set default values for `configure' scripts to share, 285 | you can create a site shell script called `config.site' that gives 286 | default values for variables like `CC', `cache_file', and `prefix'. 287 | `configure' looks for `PREFIX/share/config.site' if it exists, then 288 | `PREFIX/etc/config.site' if it exists. Or, you can set the 289 | `CONFIG_SITE' environment variable to the location of the site script. 290 | A warning: not all `configure' scripts look for a site script. 291 | 292 | Defining Variables 293 | ================== 294 | 295 | Variables not defined in a site shell script can be set in the 296 | environment passed to `configure'. However, some packages may run 297 | configure again during the build, and the customized values of these 298 | variables may be lost. In order to avoid this problem, you should set 299 | them in the `configure' command line, using `VAR=value'. For example: 300 | 301 | ./configure CC=/usr/local2/bin/gcc 302 | 303 | causes the specified `gcc' to be used as the C compiler (unless it is 304 | overridden in the site shell script). 305 | 306 | Unfortunately, this technique does not work for `CONFIG_SHELL' due to 307 | an Autoconf bug. Until the bug is fixed you can use this workaround: 308 | 309 | CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash 310 | 311 | `configure' Invocation 312 | ====================== 313 | 314 | `configure' recognizes the following options to control how it 315 | operates. 316 | 317 | `--help' 318 | `-h' 319 | Print a summary of all of the options to `configure', and exit. 320 | 321 | `--help=short' 322 | `--help=recursive' 323 | Print a summary of the options unique to this package's 324 | `configure', and exit. The `short' variant lists options used 325 | only in the top level, while the `recursive' variant lists options 326 | also present in any nested packages. 327 | 328 | `--version' 329 | `-V' 330 | Print the version of Autoconf used to generate the `configure' 331 | script, and exit. 332 | 333 | `--cache-file=FILE' 334 | Enable the cache: use and save the results of the tests in FILE, 335 | traditionally `config.cache'. FILE defaults to `/dev/null' to 336 | disable caching. 337 | 338 | `--config-cache' 339 | `-C' 340 | Alias for `--cache-file=config.cache'. 341 | 342 | `--quiet' 343 | `--silent' 344 | `-q' 345 | Do not print messages saying which checks are being made. To 346 | suppress all normal output, redirect it to `/dev/null' (any error 347 | messages will still be shown). 348 | 349 | `--srcdir=DIR' 350 | Look for the package's source code in directory DIR. Usually 351 | `configure' can determine that directory automatically. 352 | 353 | `--prefix=DIR' 354 | Use DIR as the installation prefix. *note Installation Names:: 355 | for more details, including other options available for fine-tuning 356 | the installation locations. 357 | 358 | `--no-create' 359 | `-n' 360 | Run the configure checks, but stop before creating any output 361 | files. 362 | 363 | `configure' also accepts some other, not widely useful, options. Run 364 | `configure --help' for more details. 365 | 366 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # ***************************************************************************** 2 | # Filename: Makefile.am 3 | # Description: 4 | # Copyright(c): 5 | # Author(s): Jay Cotton, Claude Sylvain 6 | # Created: 26 Mars 2011 7 | # Last modified: 17 April 2011 8 | # Notes: 9 | # ***************************************************************************** 10 | 11 | 12 | #AUTOMAKE_OPTOINS = foreign 13 | 14 | SUBDIRS = src 15 | 16 | 17 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.10.3 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, 6 | # Inc. 7 | # This Makefile.in is free software; the Free Software Foundation 8 | # gives unlimited permission to copy and/or distribute it, 9 | # with or without modifications, as long as this notice is preserved. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. 15 | 16 | @SET_MAKE@ 17 | 18 | # ***************************************************************************** 19 | # Filename: Makefile.am 20 | # Description: 21 | # Copyright(c): 22 | # Author(s): Jay Cotton, Claude Sylvain 23 | # Created: 26 Mars 2011 24 | # Last modified: 17 April 2011 25 | # Notes: 26 | # ***************************************************************************** 27 | 28 | #AUTOMAKE_OPTOINS = foreign 29 | VPATH = @srcdir@ 30 | pkgdatadir = $(datadir)/@PACKAGE@ 31 | pkglibdir = $(libdir)/@PACKAGE@ 32 | pkgincludedir = $(includedir)/@PACKAGE@ 33 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 34 | install_sh_DATA = $(install_sh) -c -m 644 35 | install_sh_PROGRAM = $(install_sh) -c 36 | install_sh_SCRIPT = $(install_sh) -c 37 | INSTALL_HEADER = $(INSTALL_DATA) 38 | transform = $(program_transform_name) 39 | NORMAL_INSTALL = : 40 | PRE_INSTALL = : 41 | POST_INSTALL = : 42 | NORMAL_UNINSTALL = : 43 | PRE_UNINSTALL = : 44 | POST_UNINSTALL = : 45 | subdir = . 46 | DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ 47 | $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \ 48 | ChangeLog INSTALL NEWS depcomp install-sh missing 49 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 50 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac 51 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 52 | $(ACLOCAL_M4) 53 | am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ 54 | configure.lineno config.status.lineno 55 | mkinstalldirs = $(install_sh) -d 56 | CONFIG_CLEAN_FILES = 57 | SOURCES = 58 | DIST_SOURCES = 59 | RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ 60 | html-recursive info-recursive install-data-recursive \ 61 | install-dvi-recursive install-exec-recursive \ 62 | install-html-recursive install-info-recursive \ 63 | install-pdf-recursive install-ps-recursive install-recursive \ 64 | installcheck-recursive installdirs-recursive pdf-recursive \ 65 | ps-recursive uninstall-recursive 66 | RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ 67 | distclean-recursive maintainer-clean-recursive 68 | ETAGS = etags 69 | CTAGS = ctags 70 | DIST_SUBDIRS = $(SUBDIRS) 71 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 72 | distdir = $(PACKAGE)-$(VERSION) 73 | top_distdir = $(distdir) 74 | am__remove_distdir = \ 75 | { test ! -d $(distdir) \ 76 | || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ 77 | && rm -fr $(distdir); }; } 78 | DIST_ARCHIVES = $(distdir).tar.gz 79 | GZIP_ENV = --best 80 | distuninstallcheck_listfiles = find . -type f -print 81 | distcleancheck_listfiles = find . -type f -print 82 | ACLOCAL = @ACLOCAL@ 83 | AMTAR = @AMTAR@ 84 | AUTOCONF = @AUTOCONF@ 85 | AUTOHEADER = @AUTOHEADER@ 86 | AUTOMAKE = @AUTOMAKE@ 87 | AWK = @AWK@ 88 | CC = @CC@ 89 | CCDEPMODE = @CCDEPMODE@ 90 | CFLAGS = @CFLAGS@ 91 | CPPFLAGS = @CPPFLAGS@ 92 | CYGPATH_W = @CYGPATH_W@ 93 | DEFS = @DEFS@ 94 | DEPDIR = @DEPDIR@ 95 | ECHO_C = @ECHO_C@ 96 | ECHO_N = @ECHO_N@ 97 | ECHO_T = @ECHO_T@ 98 | EXEEXT = @EXEEXT@ 99 | INSTALL = @INSTALL@ 100 | INSTALL_DATA = @INSTALL_DATA@ 101 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 102 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 103 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 104 | LDFLAGS = @LDFLAGS@ 105 | LIBOBJS = @LIBOBJS@ 106 | LIBS = @LIBS@ 107 | LTLIBOBJS = @LTLIBOBJS@ 108 | MAKEINFO = @MAKEINFO@ 109 | MKDIR_P = @MKDIR_P@ 110 | OBJEXT = @OBJEXT@ 111 | PACKAGE = @PACKAGE@ 112 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 113 | PACKAGE_NAME = @PACKAGE_NAME@ 114 | PACKAGE_STRING = @PACKAGE_STRING@ 115 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 116 | PACKAGE_URL = @PACKAGE_URL@ 117 | PACKAGE_VERSION = @PACKAGE_VERSION@ 118 | PATH_SEPARATOR = @PATH_SEPARATOR@ 119 | SET_MAKE = @SET_MAKE@ 120 | SHELL = @SHELL@ 121 | STRIP = @STRIP@ 122 | VERSION = @VERSION@ 123 | abs_builddir = @abs_builddir@ 124 | abs_srcdir = @abs_srcdir@ 125 | abs_top_builddir = @abs_top_builddir@ 126 | abs_top_srcdir = @abs_top_srcdir@ 127 | ac_ct_CC = @ac_ct_CC@ 128 | am__include = @am__include@ 129 | am__leading_dot = @am__leading_dot@ 130 | am__quote = @am__quote@ 131 | am__tar = @am__tar@ 132 | am__untar = @am__untar@ 133 | bindir = @bindir@ 134 | build_alias = @build_alias@ 135 | builddir = @builddir@ 136 | datadir = @datadir@ 137 | datarootdir = @datarootdir@ 138 | docdir = @docdir@ 139 | dvidir = @dvidir@ 140 | exec_prefix = @exec_prefix@ 141 | host_alias = @host_alias@ 142 | htmldir = @htmldir@ 143 | includedir = @includedir@ 144 | infodir = @infodir@ 145 | install_sh = @install_sh@ 146 | libdir = @libdir@ 147 | libexecdir = @libexecdir@ 148 | localedir = @localedir@ 149 | localstatedir = @localstatedir@ 150 | mandir = @mandir@ 151 | mkdir_p = @mkdir_p@ 152 | oldincludedir = @oldincludedir@ 153 | pdfdir = @pdfdir@ 154 | prefix = @prefix@ 155 | program_transform_name = @program_transform_name@ 156 | psdir = @psdir@ 157 | sbindir = @sbindir@ 158 | sharedstatedir = @sharedstatedir@ 159 | srcdir = @srcdir@ 160 | sysconfdir = @sysconfdir@ 161 | target_alias = @target_alias@ 162 | top_build_prefix = @top_build_prefix@ 163 | top_builddir = @top_builddir@ 164 | top_srcdir = @top_srcdir@ 165 | SUBDIRS = src 166 | all: all-recursive 167 | 168 | .SUFFIXES: 169 | am--refresh: 170 | @: 171 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 172 | @for dep in $?; do \ 173 | case '$(am__configure_deps)' in \ 174 | *$$dep*) \ 175 | echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ 176 | cd $(srcdir) && $(AUTOMAKE) --gnu \ 177 | && exit 0; \ 178 | exit 1;; \ 179 | esac; \ 180 | done; \ 181 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ 182 | cd $(top_srcdir) && \ 183 | $(AUTOMAKE) --gnu Makefile 184 | .PRECIOUS: Makefile 185 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 186 | @case '$?' in \ 187 | *config.status*) \ 188 | echo ' $(SHELL) ./config.status'; \ 189 | $(SHELL) ./config.status;; \ 190 | *) \ 191 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ 192 | cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ 193 | esac; 194 | 195 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 196 | $(SHELL) ./config.status --recheck 197 | 198 | $(top_srcdir)/configure: $(am__configure_deps) 199 | cd $(srcdir) && $(AUTOCONF) 200 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 201 | cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) 202 | 203 | # This directory's subdirectories are mostly independent; you can cd 204 | # into them and run `make' without going through this Makefile. 205 | # To change the values of `make' variables: instead of editing Makefiles, 206 | # (1) if the variable is set in `config.status', edit `config.status' 207 | # (which will cause the Makefiles to be regenerated when you run `make'); 208 | # (2) otherwise, pass the desired values on the `make' command line. 209 | $(RECURSIVE_TARGETS): 210 | @fail= failcom='exit 1'; \ 211 | for f in x $$MAKEFLAGS; do \ 212 | case $$f in \ 213 | *=* | --[!k]*);; \ 214 | *k*) failcom='fail=yes';; \ 215 | esac; \ 216 | done; \ 217 | dot_seen=no; \ 218 | target=`echo $@ | sed s/-recursive//`; \ 219 | list='$(SUBDIRS)'; for subdir in $$list; do \ 220 | echo "Making $$target in $$subdir"; \ 221 | if test "$$subdir" = "."; then \ 222 | dot_seen=yes; \ 223 | local_target="$$target-am"; \ 224 | else \ 225 | local_target="$$target"; \ 226 | fi; \ 227 | (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ 228 | || eval $$failcom; \ 229 | done; \ 230 | if test "$$dot_seen" = "no"; then \ 231 | $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ 232 | fi; test -z "$$fail" 233 | 234 | $(RECURSIVE_CLEAN_TARGETS): 235 | @fail= failcom='exit 1'; \ 236 | for f in x $$MAKEFLAGS; do \ 237 | case $$f in \ 238 | *=* | --[!k]*);; \ 239 | *k*) failcom='fail=yes';; \ 240 | esac; \ 241 | done; \ 242 | dot_seen=no; \ 243 | case "$@" in \ 244 | distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ 245 | *) list='$(SUBDIRS)' ;; \ 246 | esac; \ 247 | rev=''; for subdir in $$list; do \ 248 | if test "$$subdir" = "."; then :; else \ 249 | rev="$$subdir $$rev"; \ 250 | fi; \ 251 | done; \ 252 | rev="$$rev ."; \ 253 | target=`echo $@ | sed s/-recursive//`; \ 254 | for subdir in $$rev; do \ 255 | echo "Making $$target in $$subdir"; \ 256 | if test "$$subdir" = "."; then \ 257 | local_target="$$target-am"; \ 258 | else \ 259 | local_target="$$target"; \ 260 | fi; \ 261 | (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ 262 | || eval $$failcom; \ 263 | done && test -z "$$fail" 264 | tags-recursive: 265 | list='$(SUBDIRS)'; for subdir in $$list; do \ 266 | test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ 267 | done 268 | ctags-recursive: 269 | list='$(SUBDIRS)'; for subdir in $$list; do \ 270 | test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ 271 | done 272 | 273 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 274 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 275 | unique=`for i in $$list; do \ 276 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 277 | done | \ 278 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 279 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 280 | mkid -fID $$unique 281 | tags: TAGS 282 | 283 | TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 284 | $(TAGS_FILES) $(LISP) 285 | tags=; \ 286 | here=`pwd`; \ 287 | if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ 288 | include_option=--etags-include; \ 289 | empty_fix=.; \ 290 | else \ 291 | include_option=--include; \ 292 | empty_fix=; \ 293 | fi; \ 294 | list='$(SUBDIRS)'; for subdir in $$list; do \ 295 | if test "$$subdir" = .; then :; else \ 296 | test ! -f $$subdir/TAGS || \ 297 | tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ 298 | fi; \ 299 | done; \ 300 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 301 | unique=`for i in $$list; do \ 302 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 303 | done | \ 304 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 305 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 306 | if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ 307 | test -n "$$unique" || unique=$$empty_fix; \ 308 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 309 | $$tags $$unique; \ 310 | fi 311 | ctags: CTAGS 312 | CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 313 | $(TAGS_FILES) $(LISP) 314 | tags=; \ 315 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 316 | unique=`for i in $$list; do \ 317 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 318 | done | \ 319 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 320 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 321 | test -z "$(CTAGS_ARGS)$$tags$$unique" \ 322 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 323 | $$tags $$unique 324 | 325 | GTAGS: 326 | here=`$(am__cd) $(top_builddir) && pwd` \ 327 | && cd $(top_srcdir) \ 328 | && gtags -i $(GTAGS_ARGS) $$here 329 | 330 | distclean-tags: 331 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 332 | 333 | distdir: $(DISTFILES) 334 | $(am__remove_distdir) 335 | test -d $(distdir) || mkdir $(distdir) 336 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 337 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 338 | list='$(DISTFILES)'; \ 339 | dist_files=`for file in $$list; do echo $$file; done | \ 340 | sed -e "s|^$$srcdirstrip/||;t" \ 341 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 342 | case $$dist_files in \ 343 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 344 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 345 | sort -u` ;; \ 346 | esac; \ 347 | for file in $$dist_files; do \ 348 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 349 | if test -d $$d/$$file; then \ 350 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 351 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 352 | cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ 353 | fi; \ 354 | cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ 355 | else \ 356 | test -f $(distdir)/$$file \ 357 | || cp -p $$d/$$file $(distdir)/$$file \ 358 | || exit 1; \ 359 | fi; \ 360 | done 361 | list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ 362 | if test "$$subdir" = .; then :; else \ 363 | test -d "$(distdir)/$$subdir" \ 364 | || $(MKDIR_P) "$(distdir)/$$subdir" \ 365 | || exit 1; \ 366 | distdir=`$(am__cd) $(distdir) && pwd`; \ 367 | top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ 368 | (cd $$subdir && \ 369 | $(MAKE) $(AM_MAKEFLAGS) \ 370 | top_distdir="$$top_distdir" \ 371 | distdir="$$distdir/$$subdir" \ 372 | am__remove_distdir=: \ 373 | am__skip_length_check=: \ 374 | distdir) \ 375 | || exit 1; \ 376 | fi; \ 377 | done 378 | -find "$(distdir)" -type d ! -perm -755 \ 379 | -exec chmod u+rwx,go+rx {} \; -o \ 380 | ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ 381 | ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ 382 | ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ 383 | || chmod -R a+r $(distdir) 384 | dist-gzip: distdir 385 | tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz 386 | $(am__remove_distdir) 387 | 388 | dist-bzip2: distdir 389 | tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 390 | $(am__remove_distdir) 391 | 392 | dist-lzma: distdir 393 | tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma 394 | $(am__remove_distdir) 395 | 396 | dist-tarZ: distdir 397 | tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z 398 | $(am__remove_distdir) 399 | 400 | dist-shar: distdir 401 | shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz 402 | $(am__remove_distdir) 403 | 404 | dist-zip: distdir 405 | -rm -f $(distdir).zip 406 | zip -rq $(distdir).zip $(distdir) 407 | $(am__remove_distdir) 408 | 409 | dist dist-all: distdir 410 | tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz 411 | $(am__remove_distdir) 412 | 413 | # This target untars the dist file and tries a VPATH configuration. Then 414 | # it guarantees that the distribution is self-contained by making another 415 | # tarfile. 416 | distcheck: dist 417 | case '$(DIST_ARCHIVES)' in \ 418 | *.tar.gz*) \ 419 | GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ 420 | *.tar.bz2*) \ 421 | bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ 422 | *.tar.lzma*) \ 423 | unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ 424 | *.tar.Z*) \ 425 | uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ 426 | *.shar.gz*) \ 427 | GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ 428 | *.zip*) \ 429 | unzip $(distdir).zip ;;\ 430 | esac 431 | chmod -R a-w $(distdir); chmod a+w $(distdir) 432 | mkdir $(distdir)/_build 433 | mkdir $(distdir)/_inst 434 | chmod a-w $(distdir) 435 | dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ 436 | && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ 437 | && cd $(distdir)/_build \ 438 | && ../configure --srcdir=.. --prefix="$$dc_install_base" \ 439 | $(DISTCHECK_CONFIGURE_FLAGS) \ 440 | && $(MAKE) $(AM_MAKEFLAGS) \ 441 | && $(MAKE) $(AM_MAKEFLAGS) dvi \ 442 | && $(MAKE) $(AM_MAKEFLAGS) check \ 443 | && $(MAKE) $(AM_MAKEFLAGS) install \ 444 | && $(MAKE) $(AM_MAKEFLAGS) installcheck \ 445 | && $(MAKE) $(AM_MAKEFLAGS) uninstall \ 446 | && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ 447 | distuninstallcheck \ 448 | && chmod -R a-w "$$dc_install_base" \ 449 | && ({ \ 450 | (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ 451 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ 452 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ 453 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ 454 | distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ 455 | } || { rm -rf "$$dc_destdir"; exit 1; }) \ 456 | && rm -rf "$$dc_destdir" \ 457 | && $(MAKE) $(AM_MAKEFLAGS) dist \ 458 | && rm -rf $(DIST_ARCHIVES) \ 459 | && $(MAKE) $(AM_MAKEFLAGS) distcleancheck 460 | $(am__remove_distdir) 461 | @(echo "$(distdir) archives ready for distribution: "; \ 462 | list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ 463 | sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' 464 | distuninstallcheck: 465 | @cd $(distuninstallcheck_dir) \ 466 | && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ 467 | || { echo "ERROR: files left after uninstall:" ; \ 468 | if test -n "$(DESTDIR)"; then \ 469 | echo " (check DESTDIR support)"; \ 470 | fi ; \ 471 | $(distuninstallcheck_listfiles) ; \ 472 | exit 1; } >&2 473 | distcleancheck: distclean 474 | @if test '$(srcdir)' = . ; then \ 475 | echo "ERROR: distcleancheck can only run from a VPATH build" ; \ 476 | exit 1 ; \ 477 | fi 478 | @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ 479 | || { echo "ERROR: files left in build directory after distclean:" ; \ 480 | $(distcleancheck_listfiles) ; \ 481 | exit 1; } >&2 482 | check-am: all-am 483 | check: check-recursive 484 | all-am: Makefile 485 | installdirs: installdirs-recursive 486 | installdirs-am: 487 | install: install-recursive 488 | install-exec: install-exec-recursive 489 | install-data: install-data-recursive 490 | uninstall: uninstall-recursive 491 | 492 | install-am: all-am 493 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 494 | 495 | installcheck: installcheck-recursive 496 | install-strip: 497 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 498 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 499 | `test -z '$(STRIP)' || \ 500 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 501 | mostlyclean-generic: 502 | 503 | clean-generic: 504 | 505 | distclean-generic: 506 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 507 | 508 | maintainer-clean-generic: 509 | @echo "This command is intended for maintainers to use" 510 | @echo "it deletes files that may require special tools to rebuild." 511 | clean: clean-recursive 512 | 513 | clean-am: clean-generic mostlyclean-am 514 | 515 | distclean: distclean-recursive 516 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 517 | -rm -f Makefile 518 | distclean-am: clean-am distclean-generic distclean-tags 519 | 520 | dvi: dvi-recursive 521 | 522 | dvi-am: 523 | 524 | html: html-recursive 525 | 526 | html-am: 527 | 528 | info: info-recursive 529 | 530 | info-am: 531 | 532 | install-data-am: 533 | 534 | install-dvi: install-dvi-recursive 535 | 536 | install-dvi-am: 537 | 538 | install-exec-am: 539 | 540 | install-html: install-html-recursive 541 | 542 | install-html-am: 543 | 544 | install-info: install-info-recursive 545 | 546 | install-info-am: 547 | 548 | install-man: 549 | 550 | install-pdf: install-pdf-recursive 551 | 552 | install-pdf-am: 553 | 554 | install-ps: install-ps-recursive 555 | 556 | install-ps-am: 557 | 558 | installcheck-am: 559 | 560 | maintainer-clean: maintainer-clean-recursive 561 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 562 | -rm -rf $(top_srcdir)/autom4te.cache 563 | -rm -f Makefile 564 | maintainer-clean-am: distclean-am maintainer-clean-generic 565 | 566 | mostlyclean: mostlyclean-recursive 567 | 568 | mostlyclean-am: mostlyclean-generic 569 | 570 | pdf: pdf-recursive 571 | 572 | pdf-am: 573 | 574 | ps: ps-recursive 575 | 576 | ps-am: 577 | 578 | uninstall-am: 579 | 580 | .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ 581 | install-strip 582 | 583 | .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ 584 | all all-am am--refresh check check-am clean clean-generic \ 585 | ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ 586 | dist-lzma dist-shar dist-tarZ dist-zip distcheck distclean \ 587 | distclean-generic distclean-tags distcleancheck distdir \ 588 | distuninstallcheck dvi dvi-am html html-am info info-am \ 589 | install install-am install-data install-data-am install-dvi \ 590 | install-dvi-am install-exec install-exec-am install-html \ 591 | install-html-am install-info install-info-am install-man \ 592 | install-pdf install-pdf-am install-ps install-ps-am \ 593 | install-strip installcheck installcheck-am installdirs \ 594 | installdirs-am maintainer-clean maintainer-clean-generic \ 595 | mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ 596 | tags-recursive uninstall uninstall-am 597 | 598 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 599 | # Otherwise a system limit (for SysV at least) may be exceeded. 600 | .NOEXPORT: 601 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 4/23/2017 - I moved the code base to Mercurial, CVS is not supported anymore. 2 | 3 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | # ***************************************************************************** 2 | # Created: 20 November 2011 3 | # Last modified: 4/23/2017 4 | # Moving to Mercurial and cleaning up the code base. 5 | # ***************************************************************************** 6 | 7 | 8 | To built this package, do the following: 9 | 10 | ./autogen.sh 11 | ./configure 12 | make 13 | 14 | To install this package, do the following: 15 | 16 | make install 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This project is a fork of the Intel 8080 Assembler by Jay Cotton 2 | and Claude Sylvain. 3 | 4 | http://asm8080.sourceforge.net/ 5 | 6 | It was forked from the version 1.0.5 (from 6 January 2012). There are no 7 | functional changes in the fork. I only added simple build scripts and 8 | makefiles for Windows and Mac. 9 | 10 | To build on Windows, start your Visual Studio command line prompt and: 11 | 12 | cd windows 13 | nmake 14 | 15 | To build on Mac: 16 | 17 | cd mac 18 | make 19 | 20 | Also, there is a bug fixed when the assembler didn't return non-zero 21 | exit code on a complication error. 22 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | ******************************************************************************* 2 | Filename: TODO 3 | Description: asm8080 To Do list. 4 | Copyright(c): See below. 5 | Author(s): Jay Cotton, Claude Sylvain 6 | Created: 2007 7 | Last modified: 30 December 2011 8 | Notes: 9 | ******************************************************************************* 10 | 11 | ------------------------------------------------------------------------------- 12 | 13 | Copyright (c) <2007-2011> 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy 16 | of this software and associated documentation files (the "Software"), to 17 | deal in the Software without restriction, including without limitation the 18 | rights to use, copy, modify, merge, publish, distribute, sublicense, 19 | and/or sell copies of the Software, and to permit persons to whom the 20 | Software is furnished to do so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in 23 | all copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 28 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 30 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 31 | DEALINGS IN THE SOFTWARE. 32 | 33 | ------------------------------------------------------------------------------- 34 | 35 | 36 | ------------------------------------------------------------------------------- 37 | 30 December 2011 (Claude Sylvain) 38 | - Assembler directives that can be usefull: 39 | - LOCAL 40 | - REPT 41 | ------------------------------------------------------------------------------- 42 | 43 | ------------------------------------------------------------------------------- 44 | 26 December 2011 (Claude Sylvain) 45 | - Make the expression parser able to consider operators priority, to be 46 | able to evaluate correctly expressions like the one below: 47 | MY_SYMBOL + 16 * 64 48 | 16 * 64 must be calculated first. 49 | ------------------------------------------------------------------------------- 50 | 51 | ------------------------------------------------------------------------------- 52 | 28 December 2011 (Claude Sylvain) 53 | - Make the expression parser support inclusion of 8080 instructions 54 | in expression. 55 | Ex.: 56 | DB (ADD C) 57 | ------------------------------------------------------------------------------- 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ***************************************************************************** 3 | # Filename: autogen.sh 4 | # Description: 5 | # Copyright(c): 6 | # Author(s): Jay Cotton, Claude Sylvain 7 | # Created: 26 Mars 2011 8 | # Last modified: 17 April 2011 9 | # ***************************************************************************** 10 | 11 | 12 | echo "Generating configure files... may take a while." 13 | 14 | 15 | aclocal 16 | libtoolize --automake 17 | automake -a 18 | autoconf 19 | 20 | 21 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # ***************************************************************************** 2 | # Filename: configure.ac 3 | # Description: 4 | # Copyright(c): 5 | # Author(s): Jay Cotton, Claude Sylvain 6 | # Created: 26 Mars 2011 7 | # Last modified: 17 April 2011 8 | # 9 | # Notes: - Process this file with autoconf to produce a configure 10 | # script. 11 | # ***************************************************************************** 12 | 13 | 14 | AC_INIT(src) 15 | 16 | AM_INIT_AUTOMAKE(asm8080, 0.9.2) 17 | 18 | # Checks for programs. 19 | # -------------------- 20 | AC_PROG_CC 21 | AC_PROG_INSTALL 22 | AC_PROG_MAKE_SET 23 | 24 | # Checks for libraries. 25 | # 26 | #AM_PROG_LIBTOOL 27 | AC_CONFIG_FILES([Makefile src/Makefile]) 28 | AC_OUTPUT 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /doc/asm8080_um.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | asm8080 User Manual 3 | 4 | 5 | Cover: asm8080 V0.9.2 to V1.0.4 6 | Copyright(c): See below. 7 | Author(s): Claude Sylvain 8 | Created: 17 March 2011 9 | Last modified: 1 January 2012 10 | Revision: 0.9.7 11 | ------------------------------------------------------------------------------- 12 | 13 | 14 | ------------------------------------------------------------------------------- 15 | Copyright (c) <2007-2012> 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to 19 | deal in the Software without restriction, including without limitation the 20 | rights to use, copy, modify, merge, publish, distribute, sublicense, 21 | and/or sell copies of the Software, and to permit persons to whom the 22 | Software is furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 30 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 32 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 33 | DEALINGS IN THE SOFTWARE. 34 | ------------------------------------------------------------------------------- 35 | 36 | ------------------------------------------------------------------------------- 37 | Table of contents 38 | 39 | 1 Introduction to the assembler 40 | 1.1 Calling the assembler 41 | 2 Assembler description 42 | 2.1 Assembler options 43 | 2.2 Assembler directives 44 | 2.3 Operators 45 | 2.3.1 Standard operators 46 | 2.3.2 "C" and "Pascal" like operators 47 | 3 Assembler particularities 48 | 3.1 Expression parser 49 | ------------------------------------------------------------------------------- 50 | 51 | ------------------------------------------------------------------------------- 52 | 1 Introduction to the assembler 53 | 54 | 1.1 Calling the assembler 55 | 56 | The assembler is called by entering a line of the form: 57 | 58 | asm8080 [] 59 | 60 | Where asm8080 represents the filename of the assembler, is the name 61 | of the source file to be assembled, and [] represents zero or 62 | more assembler option specifiers. The assembler's assembly language 63 | input file is expected to have a filename extension; if none is explicitly 64 | specified, a filename extension of the form .asm is assumed. 65 | 66 | 2 Assembler description 67 | 68 | 2.1 Assembler options 69 | 70 | Assembler options are listed and described below. 71 | 72 | -h 73 | Display the help screen. 74 | 75 | -I 76 | Add directory to the include file search path. 77 | Notes: Path delimiter is not mandatory, at end of . 78 | 79 | -l 80 | This option specifies that is the name of the file 81 | in which the assembler's output listing is to be placed. The 82 | default is to place the output listing in a file having the 83 | same name as the input file, but with the filename extension 84 | .lst appended. 85 | 86 | -o 87 | This option allows the user to explicitly name the output 88 | object files, and assigns the name to them. If this 89 | option is not specified, the object files will have the same 90 | name as the input file, but with the filename extension 91 | .bin and .hex appended. If the assigned via this 92 | option have a file name extension, this filename extension 93 | will be ignored. 94 | 95 | -v 96 | Display assembler version. 97 | 98 | 2.2 Assembler directives 99 | 100 | Supported assembler directives are: 101 | 102 | ORG 103 | END 104 | 105 | INCLUDE 106 | 107 | DB 108 | DW 109 | DS 110 | 111 | IF 112 | ELSE 113 | ENDIF 114 | 115 | MACRO 116 | ENDM 117 | 118 | EQU 119 | SET 120 | 121 | 2.3 Operators 122 | 123 | 2.3.1 Standard operators 124 | 125 | Supported standard operators are: 126 | 127 | + 128 | - 129 | * 130 | / 131 | 132 | LOW 133 | HIGH 134 | 135 | MOD 136 | 137 | SHL 138 | SHR 139 | 140 | EQ 141 | NE 142 | LT 143 | LE 144 | GT 145 | GE 146 | 147 | NOT 148 | AND 149 | OR 150 | XOR 151 | 152 | 2.3.2 "C" and "Pascal" like operators 153 | 154 | Supported "C" and "Pascal" like operators are: 155 | 156 | & 157 | && 158 | 159 | | 160 | || 161 | 162 | ^ (XOR) 163 | 164 | ~ (one's complement) 165 | 166 | << 167 | >> 168 | 169 | = (Pascal equality) 170 | == 171 | 172 | > 173 | >= 174 | 175 | < 176 | <= 177 | 178 | 3 Assembler particularities 179 | 180 | 3.1 Expression parser 181 | 182 | Expression parser evaluate the expression linearly, and there is no 183 | priority on operators. 184 | So, it is important to use parentheses to set the order the expression 185 | must be evaluated. 186 | 187 | Example: 188 | 4 + 7 * 8 189 | 190 | Will be evaluated as: 191 | 192 | 4 + 7 = 11 193 | 11 * 8 = 88 194 | 195 | If you want multiplication be done first, you must add parenthesis 196 | like below: 197 | 198 | 4 + (7 * 8) 199 | 200 | Will be evaluated as: 201 | 202 | 4 + ( = 4 203 | 7 * 8 = 56 204 | ) = 60 205 | 206 | This expression parser particularity is known to cause problems when 207 | assembling some programs. 208 | ------------------------------------------------------------------------------- 209 | 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /mac/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | cc -D_TGT_OS_LINUX64=1 -o asm8080 ../src/*.c 5 | 6 | clean: 7 | -rm asm8080 8 | 9 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | # ***************************************************************************** 2 | # Filename: Makefile.am 3 | # Description: 4 | # Copyright(c): 5 | # Author(s): Jay Cotton, Claude Sylvain 6 | # Created: 26 Mars 2011 7 | # Last modified: 17 April 2011 8 | # Notes: 9 | # ***************************************************************************** 10 | 11 | 12 | #AUTOMAKE_OPTOINS = foreign 13 | 14 | #AM_CFLAGS = -g -D_TGT_M_X86 -D_TGT_OS_CYGWIN32 15 | AM_CFLAGS = -D_TGT_M_X86 -D_TGT_OS_CYGWIN32 16 | 17 | bin_PROGRAMS = asm8080 18 | 19 | asm8080_SOURCES = asm_dir.c exp_parser.c main.c opcode.c util.c msg.c 20 | 21 | #asm8080_CPPFLAGS = -D_TGT_M_X86 -D_TGT_OS_CYGWIN32 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.10.3 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, 6 | # Inc. 7 | # This Makefile.in is free software; the Free Software Foundation 8 | # gives unlimited permission to copy and/or distribute it, 9 | # with or without modifications, as long as this notice is preserved. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. 15 | 16 | @SET_MAKE@ 17 | 18 | # ***************************************************************************** 19 | # Filename: Makefile.am 20 | # Description: 21 | # Copyright(c): 22 | # Author(s): Jay Cotton, Claude Sylvain 23 | # Created: 26 Mars 2011 24 | # Last modified: 17 April 2011 25 | # Notes: 26 | # ***************************************************************************** 27 | 28 | #AUTOMAKE_OPTOINS = foreign 29 | 30 | VPATH = @srcdir@ 31 | pkgdatadir = $(datadir)/@PACKAGE@ 32 | pkglibdir = $(libdir)/@PACKAGE@ 33 | pkgincludedir = $(includedir)/@PACKAGE@ 34 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 35 | install_sh_DATA = $(install_sh) -c -m 644 36 | install_sh_PROGRAM = $(install_sh) -c 37 | install_sh_SCRIPT = $(install_sh) -c 38 | INSTALL_HEADER = $(INSTALL_DATA) 39 | transform = $(program_transform_name) 40 | NORMAL_INSTALL = : 41 | PRE_INSTALL = : 42 | POST_INSTALL = : 43 | NORMAL_UNINSTALL = : 44 | PRE_UNINSTALL = : 45 | POST_UNINSTALL = : 46 | bin_PROGRAMS = asm8080$(EXEEXT) 47 | subdir = src 48 | DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 49 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 50 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac 51 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 52 | $(ACLOCAL_M4) 53 | mkinstalldirs = $(install_sh) -d 54 | CONFIG_CLEAN_FILES = 55 | am__installdirs = "$(DESTDIR)$(bindir)" 56 | binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) 57 | PROGRAMS = $(bin_PROGRAMS) 58 | am_asm8080_OBJECTS = asm_dir.$(OBJEXT) exp_parser.$(OBJEXT) \ 59 | main.$(OBJEXT) opcode.$(OBJEXT) util.$(OBJEXT) msg.$(OBJEXT) 60 | asm8080_OBJECTS = $(am_asm8080_OBJECTS) 61 | asm8080_LDADD = $(LDADD) 62 | DEFAULT_INCLUDES = -I.@am__isrc@ 63 | depcomp = $(SHELL) $(top_srcdir)/depcomp 64 | am__depfiles_maybe = depfiles 65 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 66 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 67 | CCLD = $(CC) 68 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ 69 | SOURCES = $(asm8080_SOURCES) 70 | DIST_SOURCES = $(asm8080_SOURCES) 71 | ETAGS = etags 72 | CTAGS = ctags 73 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 74 | ACLOCAL = @ACLOCAL@ 75 | AMTAR = @AMTAR@ 76 | AUTOCONF = @AUTOCONF@ 77 | AUTOHEADER = @AUTOHEADER@ 78 | AUTOMAKE = @AUTOMAKE@ 79 | AWK = @AWK@ 80 | CC = @CC@ 81 | CCDEPMODE = @CCDEPMODE@ 82 | CFLAGS = @CFLAGS@ 83 | CPPFLAGS = @CPPFLAGS@ 84 | CYGPATH_W = @CYGPATH_W@ 85 | DEFS = @DEFS@ 86 | DEPDIR = @DEPDIR@ 87 | ECHO_C = @ECHO_C@ 88 | ECHO_N = @ECHO_N@ 89 | ECHO_T = @ECHO_T@ 90 | EXEEXT = @EXEEXT@ 91 | INSTALL = @INSTALL@ 92 | INSTALL_DATA = @INSTALL_DATA@ 93 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 94 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 95 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 96 | LDFLAGS = @LDFLAGS@ 97 | LIBOBJS = @LIBOBJS@ 98 | LIBS = @LIBS@ 99 | LTLIBOBJS = @LTLIBOBJS@ 100 | MAKEINFO = @MAKEINFO@ 101 | MKDIR_P = @MKDIR_P@ 102 | OBJEXT = @OBJEXT@ 103 | PACKAGE = @PACKAGE@ 104 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 105 | PACKAGE_NAME = @PACKAGE_NAME@ 106 | PACKAGE_STRING = @PACKAGE_STRING@ 107 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 108 | PACKAGE_URL = @PACKAGE_URL@ 109 | PACKAGE_VERSION = @PACKAGE_VERSION@ 110 | PATH_SEPARATOR = @PATH_SEPARATOR@ 111 | SET_MAKE = @SET_MAKE@ 112 | SHELL = @SHELL@ 113 | STRIP = @STRIP@ 114 | VERSION = @VERSION@ 115 | abs_builddir = @abs_builddir@ 116 | abs_srcdir = @abs_srcdir@ 117 | abs_top_builddir = @abs_top_builddir@ 118 | abs_top_srcdir = @abs_top_srcdir@ 119 | ac_ct_CC = @ac_ct_CC@ 120 | am__include = @am__include@ 121 | am__leading_dot = @am__leading_dot@ 122 | am__quote = @am__quote@ 123 | am__tar = @am__tar@ 124 | am__untar = @am__untar@ 125 | bindir = @bindir@ 126 | build_alias = @build_alias@ 127 | builddir = @builddir@ 128 | datadir = @datadir@ 129 | datarootdir = @datarootdir@ 130 | docdir = @docdir@ 131 | dvidir = @dvidir@ 132 | exec_prefix = @exec_prefix@ 133 | host_alias = @host_alias@ 134 | htmldir = @htmldir@ 135 | includedir = @includedir@ 136 | infodir = @infodir@ 137 | install_sh = @install_sh@ 138 | libdir = @libdir@ 139 | libexecdir = @libexecdir@ 140 | localedir = @localedir@ 141 | localstatedir = @localstatedir@ 142 | mandir = @mandir@ 143 | mkdir_p = @mkdir_p@ 144 | oldincludedir = @oldincludedir@ 145 | pdfdir = @pdfdir@ 146 | prefix = @prefix@ 147 | program_transform_name = @program_transform_name@ 148 | psdir = @psdir@ 149 | sbindir = @sbindir@ 150 | sharedstatedir = @sharedstatedir@ 151 | srcdir = @srcdir@ 152 | sysconfdir = @sysconfdir@ 153 | target_alias = @target_alias@ 154 | top_build_prefix = @top_build_prefix@ 155 | top_builddir = @top_builddir@ 156 | top_srcdir = @top_srcdir@ 157 | 158 | #AM_CFLAGS = -g -D_TGT_M_X86 -D_TGT_OS_CYGWIN32 159 | AM_CFLAGS = -D_TGT_M_X86 -D_TGT_OS_CYGWIN32 160 | asm8080_SOURCES = asm_dir.c exp_parser.c main.c opcode.c util.c msg.c 161 | all: all-am 162 | 163 | .SUFFIXES: 164 | .SUFFIXES: .c .o .obj 165 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 166 | @for dep in $?; do \ 167 | case '$(am__configure_deps)' in \ 168 | *$$dep*) \ 169 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 170 | && { if test -f $@; then exit 0; else break; fi; }; \ 171 | exit 1;; \ 172 | esac; \ 173 | done; \ 174 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ 175 | cd $(top_srcdir) && \ 176 | $(AUTOMAKE) --gnu src/Makefile 177 | .PRECIOUS: Makefile 178 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 179 | @case '$?' in \ 180 | *config.status*) \ 181 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 182 | *) \ 183 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 184 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 185 | esac; 186 | 187 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 188 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 189 | 190 | $(top_srcdir)/configure: $(am__configure_deps) 191 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 192 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 193 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 194 | install-binPROGRAMS: $(bin_PROGRAMS) 195 | @$(NORMAL_INSTALL) 196 | test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" 197 | @list='$(bin_PROGRAMS)'; for p in $$list; do \ 198 | p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ 199 | if test -f $$p \ 200 | ; then \ 201 | f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ 202 | echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ 203 | $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ 204 | else :; fi; \ 205 | done 206 | 207 | uninstall-binPROGRAMS: 208 | @$(NORMAL_UNINSTALL) 209 | @list='$(bin_PROGRAMS)'; for p in $$list; do \ 210 | f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ 211 | echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ 212 | rm -f "$(DESTDIR)$(bindir)/$$f"; \ 213 | done 214 | 215 | clean-binPROGRAMS: 216 | -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) 217 | asm8080$(EXEEXT): $(asm8080_OBJECTS) $(asm8080_DEPENDENCIES) 218 | @rm -f asm8080$(EXEEXT) 219 | $(LINK) $(asm8080_OBJECTS) $(asm8080_LDADD) $(LIBS) 220 | 221 | mostlyclean-compile: 222 | -rm -f *.$(OBJEXT) 223 | 224 | distclean-compile: 225 | -rm -f *.tab.c 226 | 227 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm_dir.Po@am__quote@ 228 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exp_parser.Po@am__quote@ 229 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ 230 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msg.Po@am__quote@ 231 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opcode.Po@am__quote@ 232 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ 233 | 234 | .c.o: 235 | @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 236 | @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 237 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 238 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 239 | @am__fastdepCC_FALSE@ $(COMPILE) -c $< 240 | 241 | .c.obj: 242 | @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 243 | @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 244 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 245 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 246 | @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` 247 | 248 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 249 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 250 | unique=`for i in $$list; do \ 251 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 252 | done | \ 253 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 254 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 255 | mkid -fID $$unique 256 | tags: TAGS 257 | 258 | TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 259 | $(TAGS_FILES) $(LISP) 260 | tags=; \ 261 | here=`pwd`; \ 262 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 263 | unique=`for i in $$list; do \ 264 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 265 | done | \ 266 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 267 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 268 | if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ 269 | test -n "$$unique" || unique=$$empty_fix; \ 270 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 271 | $$tags $$unique; \ 272 | fi 273 | ctags: CTAGS 274 | CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ 275 | $(TAGS_FILES) $(LISP) 276 | tags=; \ 277 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 278 | unique=`for i in $$list; do \ 279 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 280 | done | \ 281 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 282 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 283 | test -z "$(CTAGS_ARGS)$$tags$$unique" \ 284 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 285 | $$tags $$unique 286 | 287 | GTAGS: 288 | here=`$(am__cd) $(top_builddir) && pwd` \ 289 | && cd $(top_srcdir) \ 290 | && gtags -i $(GTAGS_ARGS) $$here 291 | 292 | distclean-tags: 293 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 294 | 295 | distdir: $(DISTFILES) 296 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 297 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 298 | list='$(DISTFILES)'; \ 299 | dist_files=`for file in $$list; do echo $$file; done | \ 300 | sed -e "s|^$$srcdirstrip/||;t" \ 301 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 302 | case $$dist_files in \ 303 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 304 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 305 | sort -u` ;; \ 306 | esac; \ 307 | for file in $$dist_files; do \ 308 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 309 | if test -d $$d/$$file; then \ 310 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 311 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 312 | cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ 313 | fi; \ 314 | cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ 315 | else \ 316 | test -f $(distdir)/$$file \ 317 | || cp -p $$d/$$file $(distdir)/$$file \ 318 | || exit 1; \ 319 | fi; \ 320 | done 321 | check-am: all-am 322 | check: check-am 323 | all-am: Makefile $(PROGRAMS) 324 | installdirs: 325 | for dir in "$(DESTDIR)$(bindir)"; do \ 326 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 327 | done 328 | install: install-am 329 | install-exec: install-exec-am 330 | install-data: install-data-am 331 | uninstall: uninstall-am 332 | 333 | install-am: all-am 334 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 335 | 336 | installcheck: installcheck-am 337 | install-strip: 338 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 339 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 340 | `test -z '$(STRIP)' || \ 341 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install 342 | mostlyclean-generic: 343 | 344 | clean-generic: 345 | 346 | distclean-generic: 347 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 348 | 349 | maintainer-clean-generic: 350 | @echo "This command is intended for maintainers to use" 351 | @echo "it deletes files that may require special tools to rebuild." 352 | clean: clean-am 353 | 354 | clean-am: clean-binPROGRAMS clean-generic mostlyclean-am 355 | 356 | distclean: distclean-am 357 | -rm -rf ./$(DEPDIR) 358 | -rm -f Makefile 359 | distclean-am: clean-am distclean-compile distclean-generic \ 360 | distclean-tags 361 | 362 | dvi: dvi-am 363 | 364 | dvi-am: 365 | 366 | html: html-am 367 | 368 | html-am: 369 | 370 | info: info-am 371 | 372 | info-am: 373 | 374 | install-data-am: 375 | 376 | install-dvi: install-dvi-am 377 | 378 | install-dvi-am: 379 | 380 | install-exec-am: install-binPROGRAMS 381 | 382 | install-html: install-html-am 383 | 384 | install-html-am: 385 | 386 | install-info: install-info-am 387 | 388 | install-info-am: 389 | 390 | install-man: 391 | 392 | install-pdf: install-pdf-am 393 | 394 | install-pdf-am: 395 | 396 | install-ps: install-ps-am 397 | 398 | install-ps-am: 399 | 400 | installcheck-am: 401 | 402 | maintainer-clean: maintainer-clean-am 403 | -rm -rf ./$(DEPDIR) 404 | -rm -f Makefile 405 | maintainer-clean-am: distclean-am maintainer-clean-generic 406 | 407 | mostlyclean: mostlyclean-am 408 | 409 | mostlyclean-am: mostlyclean-compile mostlyclean-generic 410 | 411 | pdf: pdf-am 412 | 413 | pdf-am: 414 | 415 | ps: ps-am 416 | 417 | ps-am: 418 | 419 | uninstall-am: uninstall-binPROGRAMS 420 | 421 | .MAKE: install-am install-strip 422 | 423 | .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ 424 | clean-generic ctags distclean distclean-compile \ 425 | distclean-generic distclean-tags distdir dvi dvi-am html \ 426 | html-am info info-am install install-am install-binPROGRAMS \ 427 | install-data install-data-am install-dvi install-dvi-am \ 428 | install-exec install-exec-am install-html install-html-am \ 429 | install-info install-info-am install-man install-pdf \ 430 | install-pdf-am install-ps install-ps-am install-strip \ 431 | installcheck installcheck-am installdirs maintainer-clean \ 432 | maintainer-clean-generic mostlyclean mostlyclean-compile \ 433 | mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ 434 | uninstall-am uninstall-binPROGRAMS 435 | 436 | 437 | #asm8080_CPPFLAGS = -D_TGT_M_X86 -D_TGT_OS_CYGWIN32 438 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 439 | # Otherwise a system limit (for SysV at least) may be exceeded. 440 | .NOEXPORT: 441 | -------------------------------------------------------------------------------- /src/asm_dir.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: asm_dir.h 3 | * Description: Assembler Directive. 4 | * Copyright(c): See below... 5 | * Author(s): Claude Sylvain 6 | * Created: 24 December 2010 7 | * Last modified: 1 January 2012 8 | * Notes: 9 | * ************************************************************************* */ 10 | 11 | /* 12 | * Copyright (c) <2007-2017> Jay Cotton 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to 16 | * deal in the Software without restriction, including without limitation the 17 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | 34 | /* ************************************************************************* 35 | * ************************************************************************* */ 36 | 37 | #ifndef _ASM_DIR_H 38 | #define _ASM_DIR_H 39 | 40 | 41 | /* ************************************************************************* 42 | * INCLUDE FILES 43 | * ************************************************************************* */ 44 | 45 | #include "project.h" 46 | 47 | 48 | /* ************************************************************************* 49 | * CONST 50 | * ************************************************************************* */ 51 | 52 | extern const keyword_t asm_dir[]; 53 | 54 | 55 | /* ************************************************************************* 56 | * VARIABLES 57 | * ************************************************************************* */ 58 | 59 | extern FILE *fp_macro; /* Macro File Pointer. */ 60 | extern int inside_macro; 61 | 62 | 63 | /* ************************************************************************* 64 | * FUNCTIONS DECLARATION 65 | * ************************************************************************* */ 66 | 67 | void asm_dir_cleanup(void); 68 | 69 | 70 | 71 | 72 | 73 | #endif 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/err_code.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: err_code.h 3 | * Description: Assembler Error Codes. 4 | * Copyright(c): See below... 5 | * Author(s): Claude Sylvain 6 | * Created: 11 December 2010 7 | * Last modified: 26 May 2013 8 | * Notes: 9 | * ************************************************************************* */ 10 | 11 | /* 12 | * Copyright (c) <2007-2017> Jay Cotton 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to 16 | * deal in the Software without restriction, including without limitation the 17 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | 34 | /* ************************************************************************* 35 | * ************************************************************************* */ 36 | 37 | #ifndef _ERR_CODE_H 38 | #define _ERR_CODE_H 39 | 40 | 41 | /* ************************************************************************* 42 | * CONSTANTS 43 | * ************************************************************************* */ 44 | 45 | #define EC_LNF 0 /* Label Not Found. */ 46 | #define EC_DL 1 /* Duplicate Label. */ 47 | #define EC_CNFK 2 /* Can Not Find Keyword. */ 48 | #define EC_BDR 3 /* Bad Destination Register. */ 49 | #define EC_BSR 4 /* Bad Source Register. */ 50 | #define EC_INO 5 /* 'if' Nesting Overflow. */ 51 | #define EC_INU 6 /* 'if' Nesting Underflow. */ 52 | #define EC_NQC 7 /* Not Quoted Character detected. */ 53 | #define EC_MF 8 /* Missing Field. */ 54 | #define EC_DWDNSS 9 /* "DW" Do Not Support String. */ 55 | #define EC_BDE 10 /* Bad Data Encoding. */ 56 | #define EC_BBD 11 /* Bad Binary Digit. */ 57 | #define EC_BOC 12 /* Bad Octal Digit. */ 58 | #define EC_BDD 13 /* Bad Decimal Digit. */ 59 | #define EC_BHD 14 /* Bad Hexadecimal Digit. */ 60 | #define EC_OOR 15 /* Operand Over Range. */ 61 | #define EC_ADAN 16 /* Already Defined As a "Name". */ 62 | #define EC_PCOR 17 /* Program Counter Over Range. */ 63 | #define EC_KTL 18 /* Keyword Too Long. */ 64 | #define EC_ETL 19 /* Equation Too Long. */ 65 | #define EC_EAE 20 /* "EQU" Already Exist. */ 66 | #define EC_ADAE 21 /* Already Defined As an "EQU". */ 67 | #define EC_SNS 22 /* String Not Supported. */ 68 | #define EC_SLTL 23 /* Source Line Too Long. */ 69 | #define EC_CAM 24 /* Can't Allocate Memory. */ 70 | #define EC_IOF 25 /* Include OverFlow. */ 71 | #define EC_NSQ 26 /* No Starting Quote. */ 72 | #define EC_NEQ 27 /* No Ending Quote. */ 73 | #define EC_BOF 28 /* Buffer OverFlow. */ 74 | #define EC_COIF 29 /* Can't Open Include File. */ 75 | #define EC_EEP 30 /* Extra Ending Parenthesis. */ 76 | #define EC_NMEP 31 /* No Matching Ending Parenthesis. */ 77 | #define EC_B16BR 32 /* Bad 16-Bit Register. */ 78 | #define EC_MAE 33 /* Memory Allocation Error. */ 79 | #define EC_EPSPOF 34 /* Expression Parser Stack Push OverFlow. */ 80 | #define EC_BD 35 /* Bad Data. */ 81 | #define EC_EIFS 36 /* Extra Input File Specified. */ 82 | #define EC_IFNTL 37 /* Input File Name Too Long. */ 83 | #define EC_EVOR 38 /* Expression Value Over Range. */ 84 | #define EC_BTS 39 /* Buffer Too Small. */ 85 | #define EC_COINF 40 /* Can't Open INput File. */ 86 | #define EC_COLF 41 /* Can't Open Listing File. */ 87 | #define EC_COBF 42 /* Can't Open Binary File. */ 88 | #define EC_EPSRUF 43 /* Expression Parser Stack Remove Underflow. */ 89 | #define EC_EPSPUF 44 /* Expression Parser Stack Pop Underflow. */ 90 | #define EC_FLBOF 45 /* "FindLabel()" Buffer OverFlow. */ 91 | #define EC_RNA 46 /* Register Not Allowed. */ 92 | #define EC_NIFSNOOS 47 /* No Input File Specified; No "-o" Option Specified. */ 93 | #define EC_COHF 48 /* Can't Open Intel Hexadecimal File. */ 94 | #define EC_NVDS 49 /* Negative Value on "DS". */ 95 | #define EC_PE 50 /* Phasing Error. */ 96 | #define EC_MHNN 51 /* Macro Have No Name. */ 97 | #define EC_IE 52 /* Internal Error. */ 98 | #define EC_MQ 53 /* Missing Quote. */ 99 | #define EC_SCNBE 54 /* String Can Not Be Evaluated. */ 100 | #define EC_MRCBUBDS 55 /* 'M' Register Can't Be Used Both as Destination and Source. */ 101 | 102 | 103 | 104 | #endif 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /src/exp_parser.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: exp_parser.c 3 | * 4 | * Description: - Expression Parser module. 5 | * 6 | * - Support most of standard 8080 assembler operators. 7 | * 8 | * - Support some "C" like operators, when language 9 | * extension is enable. 10 | * 11 | * Copyright(c): See below... 12 | * Author(s): Claude Sylvain 13 | * Created: 27 December 2010 14 | * Last modified: 20 May 2013 15 | * 16 | * Notes: - This module implement an expression parser using 17 | * DAL (Direct Algebraic Logic) format. 18 | * RPN (Reverse Polish Notation) has been dropped down, 19 | * since January 2011. 20 | * 21 | * Ref.: http://en.wikipedia.org/wiki/Reverse_Polish_notation 22 | * 23 | * - Expressions can be as simple as 1, or complex like 24 | * "xyzzy"+23/7(45*3)+16< 40 | * where is: 41 | * ("EV"+STARTOFTABLE)/4 42 | * ************************************************************************* */ 43 | 44 | /* 45 | * Copyright (c) <2007-2017> Jay Cotton 46 | * 47 | * Permission is hereby granted, free of charge, to any person obtaining a copy 48 | * of this software and associated documentation files (the "Software"), to 49 | * deal in the Software without restriction, including without limitation the 50 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 51 | * and/or sell copies of the Software, and to permit persons to whom the 52 | * Software is furnished to do so, subject to the following conditions: 53 | * 54 | * The above copyright notice and this permission notice shall be included in 55 | * all copies or substantial portions of the Software. 56 | * 57 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 58 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 59 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 60 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 61 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 62 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 63 | * DEALINGS IN THE SOFTWARE. 64 | */ 65 | 66 | 67 | /* ************************************************************************* 68 | * INCLUDE FILES 69 | * ************************************************************************* */ 70 | 71 | #include 72 | #include 73 | #include 74 | #include 75 | 76 | #include "project.h" 77 | #include "err_code.h" /* Error Codes. */ 78 | #include "war_code.h" /* Warning Codes. */ 79 | #include "util.h" 80 | #include "main.h" 81 | #include "msg.h" 82 | #include "exp_parser.h" 83 | 84 | 85 | /* ************************************************************************* 86 | * CONSTANTS 87 | * ************************************************************************* */ 88 | 89 | #define STACK_LEVELS 8 90 | 91 | 92 | /* ************************************************************************* 93 | * STRUCT 94 | * ************************************************************************* */ 95 | 96 | struct operator_t 97 | { 98 | const char *name; 99 | int op; 100 | }; 101 | 102 | 103 | /* ************************************************************************* 104 | * STRUCT 105 | * ************************************************************************* */ 106 | 107 | /* Expression Parser Stack. 108 | * ------------------------ */ 109 | struct ep_stack_t 110 | { 111 | struct ep_stack_t *prev; 112 | int word[STACK_LEVELS]; 113 | int level; 114 | }; 115 | 116 | 117 | /* ************************************************************************* 118 | * ENUM 119 | * ************************************************************************* */ 120 | 121 | /* Expression Parser Stack Operators. 122 | * Ref.: "8080-8085_assembly_language_programming_1977_intel.pdf", page 2.16 123 | * ------------------------------------------------------------------------- */ 124 | enum Operators 125 | { 126 | OP_ADD, 127 | OP_SUB, 128 | OP_MUL, 129 | OP_DIV, 130 | OP_NOT, /* Binary NOT. */ 131 | OP_AND, /* Binary AND. */ 132 | OP_OR, /* Binary OR. */ 133 | OP_XOR, /* Binary XOR. */ 134 | // OP_NUL, /* Test for null (missing) macro parameters. */ 135 | OP_HIGH, 136 | OP_LOW, 137 | OP_MOD, 138 | OP_SHL, 139 | OP_SHR, 140 | OP_EQ, 141 | OP_LT, 142 | OP_LE, 143 | OP_GT, 144 | OP_GE, 145 | #if LANG_EXTENSION 146 | OP_NE, 147 | // OP_NOT_LOG, /* Logical NOT. */ 148 | OP_AND_LOG, /* Logical AND. */ 149 | OP_OR_LOG /* Logical OR. */ 150 | #else 151 | OP_NE 152 | #endif 153 | }; 154 | 155 | 156 | /* ************************************************************************* 157 | * CONST 158 | * ************************************************************************* */ 159 | 160 | /* Private "const". 161 | * **************** */ 162 | 163 | /* Operators. 164 | * Ref.: "8080-8085_assembly_language_programming_1977_intel.pdf", page 2.16 165 | * ------------------------------------------------------------------------- */ 166 | static const struct operator_t operator[] = 167 | { 168 | // {"NUL", OP_NUL}, /* Test for null (missing) macro parameters. */ 169 | {"HIGH",OP_HIGH}, 170 | {"LOW", OP_LOW}, 171 | {"MOD", OP_MOD}, 172 | {"SHL", OP_SHL}, 173 | {"SHR", OP_SHR}, 174 | {"EQ", OP_EQ}, 175 | {"LT", OP_LT}, 176 | {"LE", OP_LE}, 177 | {"GT", OP_GT}, 178 | {"GE", OP_GE}, 179 | {"NE", OP_NE}, 180 | {"NOT", OP_NOT}, 181 | {"AND", OP_AND}, 182 | {"OR", OP_OR}, 183 | {"XOR", OP_XOR}, 184 | {NULL, 0} 185 | }; 186 | 187 | 188 | /* ************************************************************************* 189 | * FUNCTIONS DECLARATION 190 | * ************************************************************************* */ 191 | 192 | /* Private functions. 193 | * ****************** */ 194 | 195 | static int is_there_something(char *text); 196 | static int search_operator(char *text, int *text_bp); 197 | static int pop(void); 198 | static void push(int); 199 | static int add_stack(void); 200 | static int remove_stack(void); 201 | static int dalep(char *text); 202 | static void eval(void); 203 | 204 | 205 | /* ************************************************************************* 206 | * VARIABLES 207 | * ************************************************************************* */ 208 | 209 | /* Private variables. 210 | * ****************** */ 211 | 212 | /* - Expression Parser Stack. 213 | * - Notes: This is the static base stack. All other stacks 214 | * are dynamically created as needed. 215 | * */ 216 | static struct ep_stack_t ep_stack; 217 | 218 | static struct ep_stack_t *p_ep_stack = &ep_stack; 219 | 220 | 221 | /* ************************************************************************* 222 | * FUNCTIONS DEFINITION 223 | * ************************************************************************* */ 224 | 225 | 226 | /* ************************************************************************* 227 | * Function name: is_there_something 228 | * Description: Tell if There Is Something in a string. 229 | * Author(s): Claude Sylvain 230 | * Created: 20 May 2013 231 | * Last modified: 232 | * 233 | * Parameters: char *text: 234 | * Point to text that possibly hold something. 235 | * 236 | * Returns: int: 237 | * 0: There is nothing. 238 | * 1: Something was found. 239 | * 240 | * Globals: 241 | * Notes: 242 | * ************************************************************************* */ 243 | 244 | static int is_there_something(char *text) 245 | { 246 | int rv = 0; 247 | 248 | /* Loop until something is found, or end of the string. 249 | * ---------------------------------------------------- */ 250 | while (*text != '\0') 251 | { 252 | if (isspace((int) *text) != 0) 253 | { 254 | rv = 1; /* Something found. */ 255 | break; 256 | } 257 | 258 | text++; 259 | } 260 | 261 | return (rv); 262 | } 263 | 264 | 265 | /* ************************************************************************* 266 | * Function name: search_operator 267 | * Description: Search for an Operator. 268 | * Author(s): Claude Sylvain 269 | * Created: 28 December 2010 270 | * Last modified: 20 May 2013 271 | * 272 | * Parameters: char *text: 273 | * Point to text that possibly hold an operator. 274 | * 275 | * int *text_bp: 276 | * Point to a variable that receive the number of 277 | * text character globed, and have to be bypassed 278 | * by the caller. 279 | * 280 | * Returns: int: 281 | * -1 : No operator found. 282 | * > 0 : Operator value. 283 | * 284 | * Globals: 285 | * Notes: 286 | * ************************************************************************* */ 287 | 288 | static int search_operator(char *text, int *text_bp) 289 | { 290 | int rv; 291 | char *p_text; 292 | int i = 0; 293 | 294 | struct operator_t *p_operator = (struct operator_t *) operator; 295 | 296 | 297 | *text_bp = 0; 298 | 299 | p_text = (char *) malloc(strlen(text) + 1); 300 | 301 | if (p_text == NULL) 302 | { 303 | fprintf(stderr, "*** Error %d: Memory allocation error!\n", EC_MAE); 304 | 305 | return (-1); 306 | } 307 | 308 | /* Bypass space. 309 | * ------------- */ 310 | while ((isspace((int) *text) != 0) && (*text != '\0')) 311 | { 312 | (*text_bp)++; 313 | text++; 314 | } 315 | 316 | 317 | /* Get an uppercase working copy of "text". 318 | * **************************************** */ 319 | 320 | while (*text != '\0') 321 | { 322 | if (islabelchar((int) *text) == 0) 323 | break; 324 | 325 | (*text_bp)++; 326 | p_text[i++] = toupper((int) *(text++)); 327 | } 328 | 329 | p_text[i] = '\0'; 330 | 331 | /* Search the operator. 332 | * -------------------- */ 333 | while (p_operator->name != NULL) 334 | { 335 | if (strcmp(p_text, p_operator->name) == 0) 336 | break; 337 | 338 | p_operator++; 339 | } 340 | 341 | if (p_operator->name == NULL) 342 | { 343 | *text_bp = 0; 344 | rv = -1; 345 | } 346 | else 347 | rv = (p_operator->op); 348 | 349 | free(p_text); /* Free allocated memory. */ 350 | 351 | return (rv); 352 | } 353 | 354 | 355 | /* ************************************************************************* 356 | * Function name: extract_byte 357 | * Description: Extract Byte. 358 | * Author(s): Jay Cotton, Claude Sylvain 359 | * Created: 2007 360 | * Last modified: 27 December 2011 361 | * 362 | * Parameters: char *text: 363 | * ... 364 | * 365 | * Returns: int: 366 | * ... 367 | * 368 | * Globals: 369 | * Notes: 370 | * ************************************************************************* */ 371 | 372 | int extract_byte(char *text) 373 | { 374 | int accum = 0; 375 | int inc = 0; 376 | int c; 377 | 378 | 379 | /* Get numerical base increment, if possible. 380 | * ------------------------------------------ */ 381 | if (isdigit((int) *text)) 382 | inc = util_get_number_base_inc(text); 383 | 384 | /* Get the job done only if no error. 385 | * ---------------------------------- */ 386 | if (inc != -1) 387 | { 388 | while (*text) 389 | { 390 | switch (*text) 391 | { 392 | case '+': 393 | text++; 394 | 395 | /* Get numerical base increment, if possible. 396 | * ------------------------------------------ */ 397 | if (isdigit((int) *text)) 398 | inc = util_get_number_base_inc(text); 399 | 400 | if (inc == -1) 401 | { 402 | msg_error("Bad data encoding!", EC_BDE); 403 | return (accum); 404 | } 405 | 406 | break; 407 | 408 | case '-': 409 | text++; 410 | 411 | /* Get numerical base increment, if possible. 412 | * ------------------------------------------ */ 413 | if (isdigit((int) *text)) 414 | inc = util_get_number_base_inc(text); 415 | 416 | if (inc == -1) 417 | { 418 | msg_error("Bad data encoding!", EC_BDE); 419 | return (accum); 420 | } 421 | 422 | break; 423 | 424 | case '\'': 425 | text++; 426 | accum = *text; 427 | return (accum); 428 | 429 | case '\0': 430 | case '\n': 431 | case '\t': 432 | case '\"': 433 | return (accum); 434 | 435 | case ' ': 436 | if (accum) 437 | return (accum); 438 | 439 | text++; 440 | 441 | /* Get numerical base increment, if possible. 442 | * ------------------------------------------ */ 443 | if (isdigit((int) *text)) 444 | inc = util_get_number_base_inc(text); 445 | 446 | if (inc == -1) 447 | { 448 | msg_error("Bad data encoding!", EC_BDE); 449 | return (accum); 450 | } 451 | 452 | break; 453 | 454 | case ',': 455 | return (accum); 456 | 457 | default: 458 | break; 459 | } 460 | 461 | accum *= inc; 462 | c = toupper((int) *text); 463 | 464 | /* Check/Convert/Accumulate, depending of the numerical base. 465 | * ---------------------------------------------------------- */ 466 | switch (inc) 467 | { 468 | /* Binary base. 469 | * ------------ */ 470 | case 2: 471 | if ((c >= '0') && (c <= '1')) 472 | { 473 | accum += *(text++) - '0'; 474 | } 475 | else 476 | { 477 | msg_error_c("Bad binary digit!", EC_BBD, *text); 478 | 479 | return (accum); /* Punt. */ 480 | } 481 | 482 | break; 483 | 484 | /* Octal base. 485 | * ----------- */ 486 | case 8: 487 | /* Convert/Accumulate. 488 | * ------------------- */ 489 | if ((c >= '0') && (c <= '7')) 490 | { 491 | accum += *(text++) - '0'; 492 | } 493 | else 494 | { 495 | msg_error_c("Bad octal digit!", EC_BOC, *text); 496 | 497 | return (accum); /* Punt. */ 498 | } 499 | 500 | break; 501 | 502 | /* Decimal base. 503 | * ------------- */ 504 | case 10: 505 | /* Convert/Accumulate. 506 | * ------------------- */ 507 | if (isdigit(c) != 0) 508 | { 509 | accum += *(text++) - '0'; 510 | } 511 | else 512 | { 513 | msg_error_c("Bad decimal digit!", EC_BDD, *text); 514 | 515 | return (accum); /* Punt. */ 516 | } 517 | 518 | break; 519 | 520 | /* Hexadecimal base. 521 | * ----------------- */ 522 | case 16: 523 | /* Convert/Accumulate. 524 | * ------------------- */ 525 | if (isdigit(c) != 0) 526 | { 527 | accum += *(text++) - '0'; 528 | } 529 | else if ((c >= 'A') && (c <= 'F')) 530 | { 531 | accum += (toupper((int) *(text++)) - 'A') + 10; 532 | } 533 | else 534 | { 535 | msg_error_c("Bad hexadecimal digit!", EC_BHD, *text); 536 | 537 | return (accum); /* Punt. */ 538 | } 539 | 540 | break; 541 | 542 | default: 543 | msg_error_s("Bad data!", EC_BD, text); 544 | return (0); 545 | } 546 | } 547 | } 548 | else 549 | { 550 | msg_error("Bad data encoding!", EC_BDE); 551 | } 552 | 553 | return (accum); 554 | } 555 | 556 | 557 | /* ************************************************************************* 558 | * Function name: eval 559 | * Description: Evaluate an expression. 560 | * Author(s): Jay Cotton, Claude Sylvain 561 | * Created: 2007 562 | * Last modified: 17 May 2013 563 | * Parameters: void 564 | * Returns: void 565 | * Globals: 566 | * Notes: 567 | * ************************************************************************* */ 568 | 569 | static void eval(void) 570 | { 571 | /* Binary operations. 572 | * ------------------ */ 573 | if (p_ep_stack->level == 3) 574 | { 575 | int b = pop(); 576 | int op = pop(); 577 | int a = pop(); 578 | 579 | switch (op) 580 | { 581 | case OP_ADD: 582 | push(a + b); 583 | break; 584 | 585 | case OP_SUB: 586 | push(a - b); 587 | break; 588 | 589 | case OP_MUL: 590 | push(abs(a) * abs(b)); 591 | break; 592 | 593 | case OP_DIV: 594 | push(a / b); 595 | break; 596 | 597 | /* Binary "AND". 598 | * ------------- */ 599 | case OP_AND: 600 | push((a & b)); 601 | break; 602 | 603 | /* Binary "OR". 604 | * ------------ */ 605 | case OP_OR: 606 | push((a | b)); 607 | break; 608 | 609 | /* Binary "XOR". 610 | * ------------- */ 611 | case OP_XOR: 612 | push((a ^ b)); 613 | break; 614 | 615 | case OP_SHL: 616 | push(a << b); 617 | break; 618 | 619 | case OP_SHR: 620 | push(a >> b); 621 | break; 622 | 623 | case OP_MOD: 624 | push(a % b); 625 | break; 626 | 627 | case OP_EQ: 628 | push(a == b); 629 | break; 630 | 631 | /* Lower Than. 632 | * ----------- */ 633 | case OP_LT: 634 | push((a < b)); 635 | break; 636 | 637 | /* Lower of Equal. 638 | * --------------- */ 639 | case OP_LE: 640 | push((a <= b)); 641 | break; 642 | 643 | /* Greater Than. 644 | * ------------- */ 645 | case OP_GT: 646 | push((a > b)); 647 | break; 648 | 649 | /* Greater or Equal. 650 | * ----------------- */ 651 | case OP_GE: 652 | push((a >= b)); 653 | break; 654 | 655 | /* Not Equal. 656 | * ---------- */ 657 | case OP_NE: 658 | push((a != b)); 659 | break; 660 | 661 | #if LANG_EXTENSION 662 | /* Logical "AND". 663 | * -------------- */ 664 | case OP_AND_LOG: 665 | push((a != 0) && (b != 0)); /* C like behaviour. */ 666 | break; 667 | 668 | /* Logical "OR". 669 | * ------------- */ 670 | case OP_OR_LOG: 671 | push((a != 0) || (b != 0)); /* C like behaviour. */ 672 | break; 673 | #endif 674 | 675 | default: 676 | break; 677 | } 678 | } 679 | /* Unary operations. 680 | * ----------------- */ 681 | else if (p_ep_stack->level == 2) 682 | { 683 | int a = pop(); 684 | int op = pop(); 685 | 686 | 687 | switch (op) 688 | { 689 | case OP_HIGH: 690 | push((a >> 8) & 0xFF); 691 | break; 692 | 693 | case OP_LOW: 694 | push(a & 0xFF); 695 | break; 696 | 697 | case OP_ADD: 698 | push(a); 699 | break; 700 | 701 | case OP_SUB: 702 | push(-a); 703 | break; 704 | 705 | /* Binary "NOT". 706 | * ------------- */ 707 | case OP_NOT: 708 | push(~a); 709 | break; 710 | 711 | #if LANG_EXTENSION 712 | #if 0 713 | /* Logical "NOT". 714 | * -------------- */ 715 | case OP_NOT_LOG: 716 | push(a == 0); /* C like behaviour. */ 717 | break; 718 | #endif 719 | #endif 720 | 721 | default: 722 | break; 723 | } 724 | } 725 | } 726 | 727 | 728 | /* ************************************************************************* 729 | * Function name: add_stack 730 | * Description: Add Stack . 731 | * Author(s): Claude Sylvain 732 | * Created: 2 January 2011 733 | * Last modified: 27 December 2011 734 | * Parameters: void 735 | * 736 | * Returns: int: 737 | * -1 : Operation failed. 738 | * 0 : Operation successfull. 739 | * 740 | * Globals: 741 | * Notes: 742 | * Warning: 743 | * ************************************************************************* */ 744 | 745 | static int add_stack(void) 746 | { 747 | int rv = -1; 748 | 749 | /* Create a new stack. 750 | * */ 751 | struct ep_stack_t *p_ep_stack_new = 752 | (struct ep_stack_t *) malloc(sizeof (struct ep_stack_t)); 753 | 754 | /* If stack creation was successfull... 755 | * ------------------------------------ */ 756 | if (p_ep_stack_new != NULL) 757 | { 758 | /* Init. previous stack link in the newly created stack. 759 | * */ 760 | p_ep_stack_new->prev = p_ep_stack; 761 | 762 | /* Make the newly created stack the current stack. 763 | * */ 764 | p_ep_stack = p_ep_stack_new; 765 | 766 | p_ep_stack->level = 0; /* Init. level. */ 767 | rv = 0; /* Success! */ 768 | } 769 | else 770 | { 771 | msg_error("Memory Allocation Error!", EC_MAE); 772 | } 773 | 774 | return (rv); 775 | } 776 | 777 | 778 | /* ************************************************************************* 779 | * Function name: remove_stack 780 | * Description: Remove Stack . 781 | * Author(s): Claude Sylvain 782 | * Created: 2 January 2011 783 | * Last modified: 27 December 2011 784 | * Parameters: void 785 | * 786 | * Returns: int: 787 | * -1 : Operation failed. 788 | * 0 : Operation successfull. 789 | * 790 | * Globals: 791 | * Notes: 792 | * Warning: 793 | * ************************************************************************* */ 794 | 795 | static int remove_stack(void) 796 | { 797 | int rv = -1; 798 | 799 | struct ep_stack_t *p_ep_stack_prev; 800 | 801 | /* Remove only if not at stack base level. 802 | * --------------------------------------- */ 803 | if (p_ep_stack != &ep_stack) 804 | { 805 | p_ep_stack_prev = p_ep_stack->prev; /* Memoryse previous stack address. */ 806 | free(p_ep_stack); /* Free current stack. */ 807 | 808 | /* Set current stack address to the previous stack address. 809 | * */ 810 | p_ep_stack = p_ep_stack_prev; 811 | 812 | rv = 0; /* Success! */ 813 | } 814 | else 815 | msg_error("Expression parser stack remove underflow!", EC_EPSRUF); 816 | 817 | return (rv); 818 | } 819 | 820 | 821 | /* ************************************************************************* 822 | * Function name: dalep 823 | * Description: DAL (Direct Algebraic Logic) Expression Parser. 824 | * Author(s): Jay Cotton, Claude Sylvain 825 | * Created: 2007 826 | * Last modified: 20 May 2013 827 | * 828 | * Parameters: char *text: 829 | * - Point to a string that hold expression to parse 830 | * and evaluate. 831 | * 832 | * Returns: int: 833 | * ... 834 | * 835 | * Globals: 836 | * Notes: 837 | * Warning: Recursive parseing. 838 | * ************************************************************************* */ 839 | 840 | static int dalep(char *text) 841 | { 842 | int msg_displayed = 0; 843 | 844 | /* Parse all expression. 845 | * --------------------- */ 846 | while (1) 847 | { 848 | switch (*text) 849 | { 850 | 851 | #if LANG_EXTENSION 852 | /* Single character. 853 | * ----------------- */ 854 | case '\'': 855 | { 856 | text++; 857 | push(*(text++)); 858 | 859 | /* Check for matching quote. 860 | * ------------------------- */ 861 | if (*text == '\'') 862 | text++; /* Bypass quote. */ 863 | else 864 | msg_warning("Missing quote!", WC_MQ); 865 | 866 | break; 867 | } 868 | #endif 869 | 870 | #if 0 && LANG_EXTENSION 871 | /* - If string is found, alert user that string can not be 872 | * evaluated here, and bypass that string. 873 | * ------------------------------------------------------- */ 874 | case '\"': 875 | msg_error_s("String can not be evaluated here!", EC_SCNBE, text); 876 | 877 | text++; /* Bypass quote. */ 878 | 879 | /* Bypass string. 880 | * -------------- */ 881 | while (1) 882 | { 883 | if (*text == '\"') 884 | { 885 | text++; /* Bypass quote. */ 886 | break; 887 | } 888 | 889 | if (*text == '\0') 890 | { 891 | msg_error("Missing quote!", EC_MQ); 892 | return (0); 893 | } 894 | 895 | text++; 896 | } 897 | 898 | break; 899 | #endif 900 | 901 | /* Handle '('. 902 | * ----------- */ 903 | case '(': 904 | { 905 | int p_level = 0; /* Parenthesis Level. */ 906 | int val; 907 | 908 | text++; /* Bypass '(' */ 909 | add_stack(); /* Add a new Stack. */ 910 | 911 | /* Recursively Evaluate expression inside parenthise(s). 912 | * */ 913 | val = dalep(text); 914 | 915 | remove_stack(); 916 | push(val); /* Push result into the stack . */ 917 | eval(); 918 | 919 | /* Bypass expression(s) in parenthise(s). 920 | * -------------------------------------- */ 921 | while (*text != '\0') 922 | { 923 | /* Record additionnal parenthesis level. 924 | * ------------------------------------- */ 925 | if (*text == '(') 926 | p_level++; 927 | 928 | /* Check for matching ')'. 929 | * ----------------------- */ 930 | if (*text == ')') 931 | { 932 | if (--p_level < 0) 933 | break; 934 | } 935 | 936 | text++; 937 | } 938 | 939 | /* If no matching ')" found ... 940 | * ---------------------------- */ 941 | if (*text == '\0') 942 | { 943 | msg_error("No matching ')'!", EC_NMEP); 944 | } 945 | /* Bypass matching ')'. 946 | * -------------------- */ 947 | else 948 | text++; 949 | 950 | break; 951 | } 952 | 953 | /* Handle ')'. 954 | * ----------- */ 955 | case ')': 956 | eval(); /* Evaluate partial expression. */ 957 | return (p_ep_stack->word[0]); 958 | 959 | /* - "!" character tell that the next character must be 960 | * considered as normal character. 961 | * This enable to use label begining with a special 962 | * character. 963 | * So, just gobble the '!' character, then goto label 964 | * parser section. 965 | * ---------------------------------------------------- */ 966 | case '!': 967 | text++; 968 | goto dalep_01; 969 | 970 | 971 | #if LANG_EXTENSION 972 | /* "C" like "~" operators (binary NOT). 973 | * ------------------------------------ */ 974 | case '~': 975 | push(OP_NOT); 976 | text++; 977 | break; 978 | 979 | /* "C" like "|" and "||" operators. 980 | * -------------------------------- */ 981 | case '|': 982 | /* if "||" (logical OR)... 983 | * ----------------------- */ 984 | if (*(text + 1) == '|') 985 | { 986 | push(OP_OR_LOG); 987 | text += 2; 988 | } 989 | /* This is "|" (binary OR)... 990 | * -------------------------- */ 991 | else 992 | { 993 | push(OP_OR); 994 | text++; 995 | } 996 | 997 | break; 998 | 999 | /* "C" like '^' operator (binary XOR). 1000 | * ----------------------------------- */ 1001 | case '^': 1002 | push(OP_XOR); 1003 | text++; 1004 | break; 1005 | #endif 1006 | 1007 | #if LANG_EXTENSION 1008 | /* '=' operator and "C" like "==" operator. 1009 | * ---------------------------------------- */ 1010 | case '=': 1011 | { 1012 | char nc = *(text + 1); /* Next Character. */ 1013 | 1014 | push(OP_EQ); 1015 | 1016 | /* If it is a "C" like "==" operator... 1017 | * ------------------------------------ */ 1018 | if (nc == '=') 1019 | text += 2; 1020 | /* It is a Pascal like '=' operator... 1021 | * ----------------------------------- */ 1022 | else 1023 | text++; 1024 | 1025 | break; 1026 | } 1027 | #else 1028 | /* '=' operator. 1029 | * ------------- */ 1030 | case '=': 1031 | { 1032 | push(OP_EQ); 1033 | text++; 1034 | break; 1035 | } 1036 | #endif 1037 | 1038 | #if LANG_EXTENSION 1039 | /* '<' operator and "C" like "<=", "<<" operators. 1040 | * ----------------------------------------------- */ 1041 | case '<': 1042 | { 1043 | char nc = *(text + 1); /* Next Character. */ 1044 | 1045 | /* If it is a left shift... 1046 | * ------------------------ */ 1047 | if (nc == '<') 1048 | { 1049 | push(OP_SHL); 1050 | text += 2; 1051 | } 1052 | /* If it is a Lower or Equal relationnal operator. 1053 | * ----------------------------------------------- */ 1054 | else if (nc == '=') 1055 | { 1056 | push(OP_LE); 1057 | text += 2; 1058 | } 1059 | /* If it is a Lower Than relationnal operator. 1060 | * ------------------------------------------- */ 1061 | else 1062 | { 1063 | push(OP_LT); 1064 | text++; 1065 | } 1066 | 1067 | break; 1068 | } 1069 | #else 1070 | /* '<' operator. 1071 | * ------------- */ 1072 | case '<': 1073 | { 1074 | push(OP_LT); 1075 | text++; 1076 | break; 1077 | } 1078 | #endif 1079 | 1080 | #if LANG_EXTENSION 1081 | /* '>' operator and "C" like ">=", ">>" operators. 1082 | * ----------------------------------------------- */ 1083 | case '>': 1084 | { 1085 | char nc = *(text + 1); /* Next Character. */ 1086 | 1087 | /* If it is a right shift... 1088 | * ------------------------- */ 1089 | if (nc == '>') 1090 | { 1091 | push(OP_SHR); 1092 | text += 2; 1093 | } 1094 | /* If it is a Greater or Equal relationnal operator. 1095 | * ------------------------------------------------- */ 1096 | else if (nc == '=') 1097 | { 1098 | push(OP_GE); 1099 | text += 2; 1100 | } 1101 | /* If it is a Greater Than relationnal operator. 1102 | * --------------------------------------------- */ 1103 | else 1104 | { 1105 | push(OP_GT); 1106 | text++; 1107 | } 1108 | 1109 | break; 1110 | } 1111 | #else 1112 | /* '>' operator. 1113 | * ------------- */ 1114 | case '>': 1115 | { 1116 | push(OP_GT); 1117 | text++; 1118 | break; 1119 | } 1120 | #endif 1121 | 1122 | #if LANG_EXTENSION 1123 | /* - This can be an 8080 assembler concatenation operator 1124 | * or one of the "C" like "&" or "&&" operators. 1125 | * - Notes: There is a trick to be able to distinguish both kind 1126 | * of operators, and avoid conflics. Usualy, when '&' or 1127 | * "&&" "C" like operators are used, they are surrounded 1128 | * by spaces; and this is not the case for the '&' 8080 1129 | * assembler operator, since this is a concatenation 1130 | * operator. 1131 | * ------------------------------------------------------------- */ 1132 | case '&': 1133 | /* - If '&' or "&&" is followed by a Space character, this 1134 | * is probably not a concatenation operator, but 1135 | * a "C" like operator. 1136 | * ------------------------------------------------------- */ 1137 | if ( (*(text + 1) == 0x20) || 1138 | ((*(text + 1) == '&') && (*(text + 2) == 0x20))) 1139 | { 1140 | /* if "&&" (logical AND)... 1141 | * ------------------------ */ 1142 | if (*(text + 1) == '&') 1143 | { 1144 | push(OP_AND_LOG); 1145 | text += 2; 1146 | } 1147 | /* This is "&" (binary AND)... 1148 | * --------------------------- */ 1149 | else 1150 | { 1151 | push(OP_AND); 1152 | text++; 1153 | } 1154 | } 1155 | /* - '&' is a concatenation operator. 1156 | * - TODO: To implement. For the moment, just bypass 1157 | * this character. 1158 | * -------------------------------------------------- */ 1159 | else 1160 | { 1161 | text++; 1162 | goto dalep_01; 1163 | } 1164 | 1165 | break; 1166 | #else 1167 | /* - '&' is a concatenation operator. 1168 | * - TODO: To implement. For the moment, just bypass 1169 | * this character. 1170 | * -------------------------------------------------- */ 1171 | case '&': 1172 | text++; 1173 | goto dalep_01; 1174 | #endif 1175 | 1176 | case '+': 1177 | push(OP_ADD); 1178 | text++; 1179 | break; 1180 | 1181 | case '-': 1182 | push(OP_SUB); 1183 | text++; 1184 | break; 1185 | 1186 | case '*': 1187 | push(OP_MUL); 1188 | text++; 1189 | break; 1190 | 1191 | case '/': 1192 | push(OP_DIV); 1193 | text++; 1194 | break; 1195 | 1196 | case '$': 1197 | push(target.pc); 1198 | text++; 1199 | break; 1200 | 1201 | case ' ': 1202 | case '\t': 1203 | text++; 1204 | break; 1205 | 1206 | case '\0': 1207 | case '\n': 1208 | case ',': 1209 | case ';': 1210 | eval(); 1211 | return ( p_ep_stack->word[0]); 1212 | 1213 | /* Must be an operator, a label or a number. 1214 | * ----------------------------------------- */ 1215 | default: 1216 | dalep_01: 1217 | { 1218 | int text_bp; 1219 | int op; 1220 | 1221 | /* Search for an operator. 1222 | * ----------------------- */ 1223 | op = search_operator(text, &text_bp); 1224 | 1225 | /* - If this is an operator and there is something 1226 | * following the operator, this probably mean that 1227 | * this is really and operator (not a label). 1228 | * - Remarks: YES, that his. Some program, like 1229 | * the famous "als8" use operator name ("LT" and "GT") 1230 | * as label!!! 1231 | * ----------------------------------------------------- */ 1232 | if ((op != -1) && (is_there_something((text + text_bp)))) 1233 | { 1234 | push(op); /* Push Operator. */ 1235 | text += text_bp;/* Bypass operator. */ 1236 | } 1237 | /* No operator found. 1238 | * Search for a label. 1239 | * ------------------- */ 1240 | else 1241 | { 1242 | SYMBOL *Local; 1243 | char label[LABEL_SIZE_MAX]; 1244 | int i = 0; 1245 | 1246 | memset(label, 0, sizeof (label)); 1247 | 1248 | /* - First label/name character can be '?' or '@' 1249 | * special character. 1250 | * ---------------------------------------------- */ 1251 | if ((*text == '?') || (*text == '@')) 1252 | label[i++] = *(text++); 1253 | 1254 | /* Grab remaining of label/name characters. 1255 | * ---------------------------------------- */ 1256 | while (1) 1257 | { 1258 | if (islabelchar((int) *text) != 0) 1259 | { 1260 | if (i < (sizeof (label) - 3)) 1261 | { 1262 | label[i] = *(text++); 1263 | i++; 1264 | } 1265 | else 1266 | { 1267 | text++; 1268 | 1269 | /* - Display/Print error message, if not already done, 1270 | * and necessary. 1271 | * --------------------------------------------------- */ 1272 | if (!msg_displayed && (asm_pass == 1)) 1273 | { 1274 | msg_displayed = 1; /* No more message. */ 1275 | 1276 | msg_warning_s("Label too long!", WC_LTL, label); 1277 | } 1278 | } 1279 | } 1280 | else 1281 | { 1282 | break; 1283 | } 1284 | } 1285 | 1286 | /* Process label or number only if it exist. 1287 | * ----------------------------------------- */ 1288 | if (i > 0) 1289 | { 1290 | /* Could be a number. 1291 | * ------------------ */ 1292 | if (isdigit((int) label[0])) 1293 | { 1294 | push(extract_byte(label)); 1295 | eval(); 1296 | } 1297 | else 1298 | { 1299 | Local = FindLabel(label); 1300 | 1301 | if (!Local) 1302 | { 1303 | msg_error_s("Label not found!", EC_LNF, label); 1304 | return (0); 1305 | } 1306 | 1307 | push(Local->Symbol_Value); 1308 | eval(); 1309 | } 1310 | #if 0 1311 | return (p_ep_stack->word[0]); /* return top of stack. BUG NOTICE */ 1312 | #endif 1313 | } 1314 | /* Label do not exist! 1315 | * ------------------- */ 1316 | else 1317 | { 1318 | msg_error("Missing field!", EC_MF); 1319 | return (0); 1320 | } 1321 | 1322 | } /* op != -1 */ 1323 | } /* default. */ 1324 | break; 1325 | } 1326 | } 1327 | 1328 | return (0); 1329 | } 1330 | 1331 | 1332 | /* ************************************************************************* 1333 | * Function name: exp_parser 1334 | * Description: Expression Parser main entry point. 1335 | * Author(s): Jay Cotton, Claude Sylvain 1336 | * Created: 2007 1337 | * Last modified: 28 December 2011 1338 | * 1339 | * Parameters: char *text: 1340 | * - Point to a string that hold expression to parse 1341 | * and evaluate. 1342 | * 1343 | * Returns: int: 1344 | * Resulting expression Value. 1345 | * 1346 | * Globals: 1347 | * Notes: 1348 | * ************************************************************************* */ 1349 | 1350 | int exp_parser(char *text) 1351 | { 1352 | p_ep_stack->level = 0; 1353 | 1354 | return (dalep(text)); 1355 | } 1356 | 1357 | 1358 | /* ************************************************************************* 1359 | * Function name: extract_word 1360 | * Description: Extract Word. 1361 | * Author(s): Jay Cotton, Claude Sylvain 1362 | * Created: 2007 1363 | * Last modified: 27 December 2010 1364 | * 1365 | * Parameters: char *text: 1366 | * ... 1367 | * 1368 | * Returns: int: 1369 | * ... 1370 | * 1371 | * Globals: 1372 | * Notes: 1373 | * ************************************************************************* */ 1374 | 1375 | int extract_word(char *text) 1376 | { 1377 | int tmp; 1378 | 1379 | while (isspace((int) *text)) 1380 | text++; 1381 | 1382 | if (*text == '%') 1383 | return (0); 1384 | 1385 | if (*text == '\"') 1386 | { 1387 | text++; 1388 | tmp = *text << 8; 1389 | text++; 1390 | tmp |= *text; 1391 | } 1392 | else if (*text == '-') 1393 | { 1394 | text++; 1395 | tmp = extract_byte(text); 1396 | 1397 | return (-tmp); 1398 | } 1399 | else if (*text == '+') 1400 | { 1401 | text++; 1402 | tmp = extract_byte(text); 1403 | 1404 | return (+tmp); 1405 | } 1406 | else 1407 | tmp = exp_parser(text); 1408 | 1409 | return (tmp); 1410 | } 1411 | 1412 | 1413 | /* ************************************************************************* 1414 | * Function name: push 1415 | * Description: Push a value to the stack. 1416 | * Author(s): Jay Cotton, Claude Sylvain 1417 | * Created: 2007 1418 | * Last modified: 27 December 2011 1419 | * 1420 | * Parameters: int value: 1421 | * Value to push to the stack. 1422 | * 1423 | * Returns: void 1424 | * Globals: 1425 | * Notes: 1426 | * ************************************************************************* */ 1427 | 1428 | static void push(int value) 1429 | { 1430 | int i; 1431 | 1432 | /* Update stack words. 1433 | * ------------------- */ 1434 | for (i = STACK_LEVELS - 1; i > 0; i--) 1435 | p_ep_stack->word[i] = p_ep_stack->word[i -1]; 1436 | 1437 | p_ep_stack->word[0] = value; /* Add new value in the stack. */ 1438 | 1439 | /* Check for stack overflow. 1440 | * ------------------------- */ 1441 | if (++p_ep_stack->level >= (sizeof (p_ep_stack->word) / sizeof (int))) 1442 | { 1443 | p_ep_stack->level--; 1444 | msg_error("Expression parser stack push overflow!", EC_EPSPOF); 1445 | } 1446 | } 1447 | 1448 | 1449 | /* ************************************************************************* 1450 | * Function name: pop 1451 | * Description: Pop a value from the stack. 1452 | * Author(s): Jay Cotton, Claude Sylvain 1453 | * Created: 2007 1454 | * Last modified: 27 December 2011 1455 | * Parameters: void 1456 | * 1457 | * Returns: int: 1458 | * Value poped from the stack. 1459 | * 1460 | * Globals: 1461 | * Notes: 1462 | * ************************************************************************* */ 1463 | 1464 | static int pop(void) 1465 | { 1466 | int i; 1467 | int value = p_ep_stack->word[0]; /* Get value from the stack. */ 1468 | 1469 | /* Update stack words. 1470 | * ------------------- */ 1471 | for (i = 0; i < STACK_LEVELS - 1; i++) 1472 | p_ep_stack->word[i] = p_ep_stack->word[i + 1]; 1473 | 1474 | /* Check for stack underflow. 1475 | * -------------------------- */ 1476 | if (--p_ep_stack->level < 0) 1477 | { 1478 | p_ep_stack->level = 0; 1479 | msg_error("Exression parser stack pop underflow!", EC_EPSPUF); 1480 | } 1481 | 1482 | return (value); 1483 | } 1484 | -------------------------------------------------------------------------------- /src/exp_parser.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: exp_parser.h 3 | * Description: Expression Parser module. 4 | * Copyright(c): See below... 5 | * Author(s): Claude Sylvain 6 | * Created: 27 December 2010 7 | * Last modified: 4 January 2012 8 | * Notes: 9 | * ************************************************************************* */ 10 | 11 | /* 12 | * Copyright (c) <2007-2017> Jay Cotton 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to 16 | * deal in the Software without restriction, including without limitation the 17 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | 34 | /* ************************************************************************* 35 | * ************************************************************************* */ 36 | 37 | #ifndef _EXP_PARSER_H 38 | #define _EXP_PARSER_H 39 | 40 | 41 | /* ************************************************************************* 42 | * INCLUDE FILES 43 | * ************************************************************************* */ 44 | 45 | #include "project.h" 46 | 47 | 48 | /* ************************************************************************* 49 | * FUNCTIONS DECLARATION 50 | * ************************************************************************* */ 51 | 52 | int extract_byte(char *text); 53 | int extract_word(char *text); 54 | int exp_parser(char *text); 55 | 56 | 57 | 58 | 59 | 60 | #endif 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/main.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: main.h 3 | * Description: Main module for Intel 8080 Assembler. 4 | * Copyright(c): See below... 5 | * Author(s): Jay Cotton, Claude Sylvain 6 | * Created: 2007 7 | * Last modified: 1 January 2012 8 | * Notes: 9 | * ************************************************************************* */ 10 | 11 | /* 12 | * Copyright (c) <2007-2017> Jay Cotton 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to 16 | * deal in the Software without restriction, including without limitation the 17 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | 34 | /* ************************************************************************* 35 | * ************************************************************************* */ 36 | 37 | #ifndef _MAIN_H 38 | #define _MAIN_H 39 | 40 | 41 | /* ************************************************************************* 42 | * INCLUDE FILES 43 | * ************************************************************************* */ 44 | 45 | #include 46 | 47 | #include "project.h" 48 | 49 | 50 | /* ************************************************************************* 51 | * CONSTANTS 52 | * ************************************************************************* */ 53 | 54 | /* KeyWord Processing Status. 55 | * -------------------------- */ 56 | #define KWPS_NONE 0 /* No Status. */ 57 | #define BINARY_TO_DUMP 1 58 | #define PROCESSED_END 2 59 | #define COMMENT 3 60 | #define TEXT 4 61 | #define LIST_ONLY 5 62 | #define LIST_DS 6 /* List Data Storage ("DS"). */ 63 | #define LIST_BYTES 7 64 | #define LIST_WORDS 8 65 | #define LIST_STRINGS 9 66 | 67 | 68 | /* ************************************************************************* 69 | * CONST 70 | * ************************************************************************* */ 71 | 72 | extern const char *name_pgm; /* Program Name. */ 73 | 74 | 75 | /* ************************************************************************* 76 | * VARIABLES 77 | * ************************************************************************* */ 78 | 79 | extern int if_true[10]; 80 | extern int if_nest; 81 | 82 | extern int addr; 83 | extern int data_size; 84 | 85 | extern int b1; 86 | extern int b2; 87 | extern int b3; 88 | extern int b4; 89 | 90 | extern int asm_pass; /* Assembler Pass. */ 91 | 92 | extern FILE *list; 93 | 94 | extern STACK *ByteWordStack; 95 | extern TARG target; 96 | 97 | extern int type; 98 | extern int file_level; 99 | extern FILE *in_fp[FILES_LEVEL_MAX]; 100 | extern char *in_fn[FILES_LEVEL_MAX]; /* Input File Name. */ 101 | extern int codeline[FILES_LEVEL_MAX]; 102 | 103 | extern SYMBOL *Symbols; 104 | 105 | extern char *empty_string; 106 | 107 | 108 | /* ************************************************************************* 109 | * FUNCTIONS DECLARATION 110 | * ************************************************************************* */ 111 | 112 | int set_pc(int pc_value); 113 | int get_file_from_path(char *fn, char* fn_path, size_t fn_path_size); 114 | void ProcessDumpBin(void); 115 | void ProcessDumpHex(char end_of_asm); 116 | 117 | 118 | 119 | #endif 120 | 121 | 122 | -------------------------------------------------------------------------------- /src/msg.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: msg.c 3 | * Description: Manage Messages. 4 | * Copyright(c): See below... 5 | * Author(s): Claude Sylvain 6 | * Created: 1 January 2012 7 | * Last modified: 4 January 2012 8 | * ************************************************************************* */ 9 | 10 | /* 11 | * Copyright (c) <2007-2017> Jay Cotton 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to 15 | * deal in the Software without restriction, including without limitation the 16 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | * and/or sell copies of the Software, and to permit persons to whom the 18 | * Software is furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | * DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | 33 | /* ************************************************************************* 34 | * INCLUDE FILES 35 | * ************************************************************************* */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #include "project.h" 43 | #include "main.h" 44 | #include "msg.h" 45 | 46 | 47 | /* ************************************************************************* 48 | * CONST 49 | * ************************************************************************* */ 50 | 51 | /* Private "const". 52 | * **************** */ 53 | 54 | static const char *str_err = "Error"; 55 | static const char *str_war = "Warning"; 56 | 57 | 58 | /* ************************************************************************* 59 | * FUNCTIONS DECLARATION 60 | * ************************************************************************* */ 61 | 62 | /* Private functions. 63 | * ****************** */ 64 | 65 | static void print_msg(const char *str_type, char *msg, int code); 66 | static void print_msg_c(const char *str_type, char *msg, int code, char c); 67 | static void print_msg_s(const char *str_type, char *msg, int code, char *s); 68 | static void print_msg_d(const char *str_type, char *msg, int code, int d); 69 | 70 | 71 | /* ************************************************************************* 72 | * FUNCTIONS DEFINITION 73 | * ************************************************************************* */ 74 | 75 | 76 | /* ************************************************************************* 77 | * Function name: print_msg 78 | * Description: Print Message, without additionnal information. 79 | * Author(s): Claude Sylvain 80 | * Created: 27 December 2011 81 | * Last modified: 82 | * 83 | * Parameters: const char *str_type: 84 | * String that hold message type. 85 | * 86 | * char *msg: 87 | * Message to display. 88 | * 89 | * int code: 90 | * Error or warning Code. 91 | * 92 | * Returns: void 93 | * Globals: 94 | * Notes: 95 | * ************************************************************************* */ 96 | 97 | static void print_msg(const char *str_type, char *msg, int code) 98 | { 99 | /* Print message only on second assembly pass. 100 | * */ 101 | if (asm_pass != 1) return; 102 | 103 | if (list != NULL) 104 | { 105 | fprintf(list, "*** %s %d in \"%s\": %s\n", str_type, 106 | code, in_fn[file_level], msg); 107 | } 108 | 109 | fprintf(stderr, "*** %s %d in \"%s\" @%d: %s\n", str_type, 110 | code, in_fn[file_level], codeline[file_level], 111 | msg); 112 | } 113 | 114 | 115 | /* ************************************************************************* 116 | * Function name: print_msg_c 117 | * 118 | * Description: - Print Error Message, with additionnal information using 119 | * a character. 120 | * 121 | * Author(s): Claude Sylvain 122 | * Created: 27 December 2011 123 | * Last modified: 124 | * 125 | * Parameters: const char *str_type: 126 | * String that hold message type. 127 | * 128 | * char *msg: 129 | * Message to display. 130 | * 131 | * int code: 132 | * Error or warning Code. 133 | * 134 | * char c: 135 | * Character to display. 136 | * 137 | * Returns: void 138 | * Globals: 139 | * Notes: 140 | * ************************************************************************* */ 141 | 142 | static void print_msg_c(const char *str_type, char *msg, int code, char c) 143 | { 144 | /* Print message only on second assembly pass. 145 | * */ 146 | if (asm_pass != 1) return; 147 | 148 | if (list != NULL) 149 | { 150 | fprintf(list, "*** %s %d in \"%s\": %s (\"%c\")\n", str_type, 151 | code, in_fn[file_level], msg, c); 152 | } 153 | 154 | fprintf(stderr, "*** %s %d in \"%s\" @%d: %s (\"%c\")\n", str_type, 155 | code, in_fn[file_level], codeline[file_level], msg, c); 156 | } 157 | 158 | 159 | /* ************************************************************************* 160 | * Function name: print_msg_s 161 | * 162 | * Description: - Print Error Message, with additionnal information using 163 | * a string. 164 | * 165 | * Author(s): Claude Sylvain 166 | * Created: 27 December 2011 167 | * Last modified: 168 | * 169 | * Parameters: const char *str_type: 170 | * String that hold message type. 171 | * 172 | * char *msg: 173 | * Message to display. 174 | * 175 | * int code: 176 | * Error or warning Code. 177 | * 178 | * char *s: 179 | * String to display. 180 | * 181 | * Returns: void 182 | * Globals: 183 | * Notes: 184 | * ************************************************************************* */ 185 | 186 | static void print_msg_s(const char *str_type, char *msg, int code, char *s) 187 | { 188 | /* Print message only on second assembly pass. 189 | * */ 190 | if (asm_pass != 1) return; 191 | 192 | if (list != NULL) 193 | { 194 | fprintf(list, "*** %s %d in \"%s\": %s (\"%s\")\n", str_type, 195 | code, in_fn[file_level], msg, s); 196 | } 197 | 198 | fprintf(stderr, "*** %s %d in \"%s\" @%d: %s (\"%s\")\n", str_type, 199 | code, in_fn[file_level], codeline[file_level], msg, s); 200 | } 201 | 202 | 203 | /* ************************************************************************* 204 | * Function name: print_msg_d 205 | * 206 | * Description: - Print Error Message, with additionnal information using 207 | * an integer displayed in Decimal. 208 | * 209 | * Author(s): Claude Sylvain 210 | * Created: 27 December 2011 211 | * Last modified: 212 | * 213 | * Parameters: const char *str_type: 214 | * String that hold message type. 215 | * 216 | * char *msg: 217 | * Message to display. 218 | * 219 | * int code: 220 | * Error or warning Code. 221 | * 222 | * int d: 223 | * Integer to display. 224 | * 225 | * Returns: void 226 | * Globals: 227 | * Notes: 228 | * ************************************************************************* */ 229 | 230 | static void print_msg_d(const char *str_type, char *msg, int code, int d) 231 | { 232 | /* Print message only on second assembly pass. 233 | * */ 234 | if (asm_pass != 1) return; 235 | 236 | if (list != NULL) 237 | { 238 | fprintf(list, "*** %s %d in \"%s\": %s (%d)\n", str_type, 239 | code, in_fn[file_level], msg, d); 240 | } 241 | 242 | fprintf(stderr, "*** %s %d in \"%s\" @%d: %s (%d)\n", str_type, 243 | code, in_fn[file_level], codeline[file_level], msg, d); 244 | } 245 | 246 | 247 | /* ************************************************************************* 248 | * Function name: msg_error 249 | * Description: Print Error Message, without additionnal information. 250 | * Author(s): Claude Sylvain 251 | * Created: 27 December 2011 252 | * Last modified: 253 | * 254 | * Parameters: char *msg: 255 | * Message to display. 256 | * 257 | * int err_code: 258 | * Error Code. 259 | * 260 | * Returns: void 261 | * Globals: 262 | * Notes: 263 | * ************************************************************************* */ 264 | 265 | void msg_error(char *msg, int err_code) 266 | { 267 | print_msg(str_err, msg, err_code); 268 | } 269 | 270 | 271 | /* ************************************************************************* 272 | * Function name: msg_error_c 273 | * 274 | * Description: - Print Error Message, with additionnal information using 275 | * a character. 276 | * 277 | * Author(s): Claude Sylvain 278 | * Created: 27 December 2011 279 | * Last modified: 280 | * 281 | * Parameters: char *msg: 282 | * Message to display. 283 | * 284 | * int err_code: 285 | * Error Code. 286 | * 287 | * char c: 288 | * Character to display. 289 | * 290 | * Returns: void 291 | * Globals: 292 | * Notes: 293 | * ************************************************************************* */ 294 | 295 | void msg_error_c(char *msg, int err_code, char c) 296 | { 297 | print_msg_c(str_err, msg, err_code, c); 298 | } 299 | 300 | 301 | /* ************************************************************************* 302 | * Function name: msg_error_s 303 | * 304 | * Description: - Print Error Message, with additionnal information using 305 | * a string. 306 | * 307 | * Author(s): Claude Sylvain 308 | * Created: 27 December 2011 309 | * Last modified: 310 | * 311 | * Parameters: char *msg: 312 | * Message to display. 313 | * 314 | * int err_code: 315 | * Error Code. 316 | * 317 | * char *s: 318 | * String to display. 319 | * 320 | * Returns: void 321 | * Globals: 322 | * Notes: 323 | * ************************************************************************* */ 324 | 325 | void msg_error_s(char *msg, int err_code, char *s) 326 | { 327 | print_msg_s(str_err, msg, err_code, s); 328 | } 329 | 330 | 331 | /* ************************************************************************* 332 | * Function name: msg_error_d 333 | * 334 | * Description: - Print Error Message, with additionnal information using 335 | * an integer displayed as Decimal. 336 | * 337 | * Author(s): Claude Sylvain 338 | * Created: 27 December 2011 339 | * Last modified: 340 | * 341 | * Parameters: char *msg: 342 | * Message to display. 343 | * 344 | * int err_code: 345 | * Error Code. 346 | * 347 | * int d: 348 | * Integer to display. 349 | * 350 | * Returns: void 351 | * Globals: 352 | * Notes: 353 | * ************************************************************************* */ 354 | 355 | void msg_error_d(char *msg, int err_code, int d) 356 | { 357 | print_msg_d(str_err, msg, err_code, d); 358 | } 359 | 360 | 361 | /* ************************************************************************* 362 | * Function name: msg_warning 363 | * Description: Print Warning Message, without additionnal information. 364 | * Author(s): Claude Sylvain 365 | * Created: 27 December 2011 366 | * Last modified: 367 | * 368 | * Parameters: char *msg: 369 | * Message to display. 370 | * 371 | * int war_code: 372 | * Warning Code. 373 | * 374 | * Returns: void 375 | * Globals: 376 | * Notes: 377 | * ************************************************************************* */ 378 | 379 | void msg_warning(char *msg, int war_code) 380 | { 381 | print_msg(str_war, msg, war_code); 382 | } 383 | 384 | 385 | /* ************************************************************************* 386 | * Function name: msg_warning_c 387 | * 388 | * Description: - Print Warning Message, with additionnal information using 389 | * a character. 390 | * 391 | * Author(s): Claude Sylvain 392 | * Created: 27 December 2011 393 | * Last modified: 394 | * 395 | * Parameters: char *msg: 396 | * Message to display. 397 | * 398 | * int war_code: 399 | * Warning Code. 400 | * 401 | * char c: 402 | * Character to display. 403 | * 404 | * Returns: void 405 | * Globals: 406 | * Notes: 407 | * ************************************************************************* */ 408 | 409 | void msg_warning_c(char *msg, int war_code, char c) 410 | { 411 | print_msg_c(str_war, msg, war_code, c); 412 | } 413 | 414 | 415 | /* ************************************************************************* 416 | * Function name: msg_warning_s 417 | * 418 | * Description: - Print Warning Message, with additionnal information using 419 | * a string. 420 | * 421 | * Author(s): Claude Sylvain 422 | * Created: 27 December 2011 423 | * Last modified: 424 | * 425 | * Parameters: char *msg: 426 | * Message to display. 427 | * 428 | * int war_code: 429 | * Warning Code. 430 | * 431 | * char *s: 432 | * String to display. 433 | * 434 | * Returns: void 435 | * Globals: 436 | * Notes: 437 | * ************************************************************************* */ 438 | 439 | void msg_warning_s(char *msg, int war_code, char *s) 440 | { 441 | print_msg_s(str_war, msg, war_code, s); 442 | } 443 | 444 | 445 | 446 | 447 | 448 | 449 | -------------------------------------------------------------------------------- /src/msg.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: msg.h 3 | * Description: Manage Messages. 4 | * Copyright(c): See below... 5 | * Author(s): Claude Sylvain 6 | * Created: 27 December 2011 7 | * Last modified: 1 January 2012 8 | * Notes: 9 | * ************************************************************************* */ 10 | 11 | /* 12 | * Copyright (c) <2007-2017> Jay Cotton 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to 16 | * deal in the Software without restriction, including without limitation the 17 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | 34 | /* ************************************************************************* 35 | * ************************************************************************* */ 36 | 37 | #ifndef _MSG_H 38 | #define _MSG_H 39 | 40 | 41 | /* ************************************************************************* 42 | * INCLUDE FILES 43 | * ************************************************************************* */ 44 | 45 | #include "project.h" 46 | 47 | 48 | /* ************************************************************************* 49 | * FUNCTIONS DECLARATION 50 | * ************************************************************************* */ 51 | 52 | void msg_error(char *msg, int err_code); 53 | void msg_error_c(char *msg, int err_code, char c); 54 | void msg_error_s(char *msg, int err_code, char *s); 55 | void msg_error_d(char *msg, int err_code, int d); 56 | 57 | void msg_warning(char *msg, int war_code); 58 | void msg_warning_c(char *msg, int war_code, char c); 59 | void msg_warning_s(char *msg, int war_code, char *s); 60 | 61 | 62 | 63 | 64 | #endif 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/opcode.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: opcode.h 3 | * Description: Opcodes. 4 | * Copyright(c): See below... 5 | * Author(s): Claude Sylvain 6 | * Created: 24 December 2010 7 | * Last modified: 26 May 2013 8 | * Notes: 9 | * ************************************************************************* */ 10 | 11 | /* 12 | * Copyright (c) <2007-2017> Jay Cotton 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to 16 | * deal in the Software without restriction, including without limitation the 17 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | 34 | /* ************************************************************************* 35 | * ************************************************************************* */ 36 | 37 | #ifndef _OPCODE_H 38 | #define _OPCODE_H 39 | 40 | 41 | /* ************************************************************************* 42 | * INCLUDE FILES 43 | * ************************************************************************* */ 44 | 45 | #include "project.h" 46 | 47 | 48 | /* ************************************************************************* 49 | * CONST 50 | * ************************************************************************* */ 51 | 52 | extern const keyword_t OpCodes[]; 53 | 54 | 55 | /* ************************************************************************* 56 | * FUNCTIONS DECLARATION 57 | * ************************************************************************* */ 58 | 59 | void opcode_get_inst_cyc(uint8_t inst_cyc_p[]); 60 | 61 | 62 | #endif 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/project.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: project.h 3 | * Description: Project header file. 4 | * Copyright(c): See below... 5 | * Author(s): Claude Sylvain 6 | * Created: 2010-12-11 7 | * Last modified: 2015-08-30 8 | * Notes: 9 | * ************************************************************************* */ 10 | 11 | /* 12 | * Copyright (c) <2007-2017> 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to 16 | * deal in the Software without restriction, including without limitation the 17 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | 34 | /* ************************************************************************* 35 | * ************************************************************************* */ 36 | 37 | #ifndef _PROJECT_H 38 | #define _PROJECT_H 39 | 40 | 41 | /* ************************************************************************* 42 | * INCLUDE 43 | * ************************************************************************* */ 44 | 45 | #if defined (_TGT_OS_CYGWIN32) || defined (_TGT_OS_CYGWIN64) || \ 46 | defined (_TGT_OS_LINUX32) || defined (_TGT_OS_LINUX64) || \ 47 | defined (_TGT_OS_SOLARIS32) || defined (_TGT_OS_SOLARIS64) 48 | #include 49 | #endif 50 | 51 | #if defined (_TGT_OS_CYGWIN32) || defined (_TGT_OS_CYGWIN64) || \ 52 | defined (_TGT_OS_LINUX32) || defined (_TGT_OS_LINUX64) || \ 53 | defined (_TGT_OS_WIN32) || defined (_TGT_OS_WIN64) 54 | #include 55 | #elif defined (_TGT_OS_SOLARIS32) || defined (_TGT_OS_SOLARIS64) 56 | #include 57 | #else 58 | #error !!! Unsupported operating system! 59 | #endif 60 | 61 | #if defined (_TGT_OS_CYGWIN32) || defined (_TGT_OS_CYGWIN64) || \ 62 | defined (_TGT_OS_LINUX32) || defined (_TGT_OS_LINUX64) 63 | #include 64 | #endif 65 | 66 | 67 | /* ************************************************************************* 68 | * CONSTANTS 69 | * ************************************************************************* */ 70 | 71 | #define SRC_LINE_WIDTH_MAX 256 /* Source Line Maximum Width. */ 72 | #define FILES_LEVEL_MAX 16 /* Maximum Files Level. */ 73 | 74 | #define EQUATION_SIZE_MAX 160 /* Equation maximum size. */ 75 | #define SYMBOL_SIZE_MAX 64 /* Symbol Maximum Size. */ 76 | 77 | /* Label Maximum Size. 78 | * Notes: This value is (only) 6 in some 8080 legacy assemblers. 79 | * */ 80 | #define LABEL_SIZE_MAX SYMBOL_SIZE_MAX 81 | 82 | /* When "1", accept '_' character in label/name. 83 | * */ 84 | #define ACCEPT_UNDERSCORE_CHAR_IN_LN 1 85 | 86 | /* Define to 1 to make "asm8080" support language extension. 87 | * Language extension are: 88 | * "C" like operators: 89 | * >>, <<, ==, =, <, <=, >, >=, , ~, |, ||, ^, &, && 90 | * Pascal like operators: 91 | * = 92 | * */ 93 | #define LANG_EXTENSION 1 94 | 95 | /* Temporary debug. 96 | * */ 97 | #define DEBUG_TMP_ACTIVE 0 98 | 99 | 100 | /* ************************************************************************* 101 | * MACROS 102 | * ************************************************************************* */ 103 | 104 | /* Define Path Separator accordingly to the operating system. 105 | * ---------------------------------------------------------- */ 106 | #if defined (_TGT_OS_CYGWIN32) || defined (_TGT_OS_CYGWIN64) || \ 107 | defined (_TGT_OS_LINUX32) || defined (_TGT_OS_LINUX64) || \ 108 | defined (_TGT_OS_SOLARIS32) || defined (_TGT_OS_SOLARIS64) 109 | #define PATH_SEPARATOR_CHAR '/' 110 | #define PATH_SEPARATOR_STR "/" 111 | #elif defined (_TGT_OS_WIN32) || defined (_TGT_OS_WIN64) 112 | #define PATH_SEPARATOR_CHAR '\\' 113 | #define PATH_SEPARATOR_STR "\\" 114 | #else 115 | #error !!! Unsupported operating system! 116 | #endif 117 | 118 | 119 | /* ************************************************************************* 120 | * TYPEDEF 121 | * ************************************************************************* */ 122 | 123 | /* - In Windows, "stdint.h" do not exist and some types found in 124 | * "stdint.h" must be added. 125 | * ------------------------------------------------------------- */ 126 | #if defined (_TGT_OS_WIN32) || defined (_TGT_OS_WIN64) 127 | typedef unsigned char uint8_t; 128 | typedef unsigned short uint16_t; 129 | typedef unsigned int uint32_t; 130 | #endif 131 | 132 | /* Types of Symbols. 133 | * ----------------- */ 134 | enum symbol_type_t 135 | { 136 | SYMBOL_LABEL, 137 | SYMBOL_NAME, 138 | SYMBOL_NAME_EQU, 139 | SYMBOL_NAME_SET 140 | }; 141 | 142 | /* Symbol table storage. 143 | * --------------------- */ 144 | typedef struct Symbol 145 | { 146 | char *Symbol_Name; 147 | int Symbol_Value; 148 | enum symbol_type_t Symbol_Type; 149 | int code_line; 150 | char *src_filename; 151 | void *next; 152 | } SYMBOL; 153 | 154 | /* Binary stack for lister. 155 | * ------------------------ */ 156 | typedef struct Stack 157 | { 158 | int word; 159 | void *next; 160 | } STACK; 161 | 162 | typedef struct Instructions 163 | { 164 | const char *Name; 165 | int (*fnc) (char *, char *); 166 | } keyword_t; 167 | 168 | /* Targeted binary handling storage. 169 | * */ 170 | typedef struct targ 171 | { 172 | int addr; /* Address. */ 173 | int pc; /* Program Counter. */ 174 | int pc_org; /* Program Counter, value set by "ORG" directive. */ 175 | int pc_lowest; /* Program Counter, Lowest value. */ 176 | int pc_highest; /* Program Counter, Highest value. */ 177 | } TARG; 178 | 179 | 180 | #endif 181 | 182 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /src/util.c: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: util.c 3 | * Description: Utilities. 4 | * Copyright(c): See below... 5 | * Author(s): Claude Sylvain 6 | * Created: 23 December 2010 7 | * Last modified: 4 January 2012 8 | * ************************************************************************* */ 9 | 10 | /* 11 | * Copyright (c) <2007-2017> Jay Cotton 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to 15 | * deal in the Software without restriction, including without limitation the 16 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 17 | * and/or sell copies of the Software, and to permit persons to whom the 18 | * Software is furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | * DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | 33 | /* ************************************************************************* 34 | * INCLUDE FILES 35 | * ************************************************************************* */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #include "project.h" 43 | #include "err_code.h" 44 | #include "main.h" 45 | #include "msg.h" 46 | #include "util.h" 47 | 48 | 49 | /* ************************************************************************* 50 | * FUNCTIONS DEFINITION 51 | * ************************************************************************* */ 52 | 53 | 54 | /* ************************************************************************* 55 | * Function name: islabelchar 56 | * Description: Tell if character can be a label character. 57 | * Author(s): Claude Sylvain 58 | * Created: 8 January 2011 59 | * Last modified: 25 December 2011 60 | * 61 | * Parameters: int c: 62 | * The character to test. 63 | * 64 | * Returns: int: 65 | * 0 : Not a label character. 66 | * != 0 : Is a label character. 67 | * 68 | * Globals: 69 | * 70 | * Notes: - Do not check for label/name first character, that 71 | * can be '?' or '@' special character. 72 | * 73 | * - '_' character is not accepted as a valid character in 74 | * legacy 8080 assemblers. 75 | * ************************************************************************* */ 76 | 77 | int islabelchar(int c) 78 | { 79 | /* If Accepting Underscore Character in Label/Name. 80 | * ------------------------------------------------ */ 81 | #if ACCEPT_UNDERSCORE_CHAR_IN_LN 82 | return ((isalnum(c) != 0) || (c == '_')); 83 | #else 84 | return (isalnum(c) != 0); 85 | #endif 86 | } 87 | 88 | 89 | /* ************************************************************************* 90 | * Function name: check_evor 91 | * 92 | * Description: - Check for Expression Value Over Range, and display/print 93 | * an error message if an over range is detected. 94 | * 95 | * Author(s): Claude Sylvain 96 | * Created: 4 December 2011 97 | * Last modified: 27 December 2011 98 | * 99 | * Parameters: int value: 100 | * Expression Value to check. 101 | * 102 | * int limit: 103 | * Expression value Limit. 104 | * 105 | * Returns: int: 106 | * -1 : Over Range. 107 | * 0 : Good Range. 108 | * 109 | * Globals: None. 110 | * Notes: 111 | * ************************************************************************* */ 112 | 113 | int check_evor(int value, int limit) 114 | { 115 | int rv = 0; 116 | 117 | // if ((value > limit) && (asm_pass == 1)) 118 | if (value > limit) 119 | { 120 | msg_error_d("Expression value over range!", EC_EVOR, value); 121 | rv = -1; 122 | } 123 | 124 | return (rv); 125 | } 126 | 127 | 128 | /* ************************************************************************* 129 | * Function name: check_oor 130 | * 131 | * Description: - Check for Operand Over Range, and display/print 132 | * an error message if an over range is detected. 133 | * 134 | * Author(s): Claude Sylvain 135 | * Created: 24 December 2010 136 | * Last modified: 27 December 2011 137 | * 138 | * Parameters: int value: 139 | * Value to check. 140 | * 141 | * int limit: 142 | * Operand Limit. 143 | * 144 | * Returns: int: 145 | * -1 : Over Range. 146 | * 0 : Good Range. 147 | * 148 | * Globals: None. 149 | * Notes: 150 | * ************************************************************************* */ 151 | 152 | int check_oor(int value, int limit) 153 | { 154 | int rv = 0; 155 | 156 | // if ((value > limit) && (asm_pass == 1)) 157 | if (value > limit) 158 | { 159 | msg_error_d("Operand over range!", EC_OOR, value); 160 | rv = -1; 161 | } 162 | 163 | return (rv); 164 | } 165 | 166 | 167 | /* ************************************************************************* 168 | * Function name: FindLabel 169 | * Description: Find a Label (actually a symbol). 170 | * Author(s): Jay Cotton, Claude Sylvain 171 | * Created: 2007 172 | * Last modified: 27 December 2011 173 | * 174 | * Parameters: char *text: 175 | * "text" that possibly contain label. 176 | * 177 | * Returns: SYMBOL *: 178 | * Pointer to the structure that hold symbol. 179 | * 180 | * Globals: 181 | * Notes: Linked list, linear search, string compare real dumb. 182 | * ************************************************************************* */ 183 | 184 | SYMBOL *FindLabel(char *text) 185 | { 186 | char tmp[SYMBOL_SIZE_MAX]; 187 | 188 | SYMBOL *Local = Symbols; 189 | int i = 0; 190 | 191 | 192 | /* TODO: Is this standard Intel assembler code? 193 | * -------------------------------------------- */ 194 | if (*text == '&') tmp[i++] = *text++; 195 | if (*text == '%') tmp[i++] = *text++; 196 | 197 | /* - First label/name character can be '?' or '@' 198 | * special character. 199 | * ---------------------------------------------- */ 200 | if ((*text == '?') || (*text == '@')) 201 | tmp[i++] = *(text++); 202 | 203 | while (islabelchar((int) *text) != 0) 204 | { 205 | tmp[i] = *text++; 206 | 207 | /* Check for buffer overflow. 208 | * -------------------------- */ 209 | if (++i >= sizeof (tmp)) 210 | { 211 | --i; 212 | msg_error("\"FindLabel\" buffer overflow!", EC_FLBOF); 213 | break; 214 | } 215 | } 216 | 217 | tmp[i] = '\0'; /* String delimitor. */ 218 | 219 | while (Local->next) 220 | { 221 | if (!strcmp(Local->Symbol_Name, tmp)) 222 | return (Local); 223 | 224 | Local = (SYMBOL *) Local->next; 225 | } 226 | 227 | return (NULL); 228 | } 229 | 230 | 231 | /* ************************************************************************* 232 | * Function name: AddLabel 233 | * Description: Add a Label to the label's linked list. 234 | * Author(s): Jay Cotton, Claude Sylvain 235 | * Created: 2007 236 | * Last modified: 27 December 2011 237 | * 238 | * Parameters: char *label: 239 | * String that contain Label to Add. 240 | * 241 | * Returns: int: 242 | * -1 : Can not add label because it already exist. 243 | * 0 : Label/name added successfully. 244 | * 245 | * Globals: 246 | * Notes: 247 | * ************************************************************************* */ 248 | 249 | int AddLabel(char *label) 250 | { 251 | int rv = 0; 252 | SYMBOL *Local = Symbols; 253 | int phantom = 0; 254 | 255 | 256 | if (*label == '&') 257 | label++; 258 | 259 | if (*label == '%') 260 | { 261 | label++; 262 | phantom++; 263 | } 264 | 265 | /* If label/name already exist... 266 | * ------------------------------ */ 267 | if (FindLabel(label) != NULL) 268 | { 269 | if (phantom == 0) 270 | { 271 | if (list != NULL) 272 | { 273 | /* - Notes: Since this error is printed on assembler pass #1 only, 274 | * it is printed at beginning of the listing file. 275 | * So, we have to tell where is the error, by adding the 276 | * line number to the print out. 277 | * */ 278 | fprintf( list, 279 | "*** Error %d in \"%s\" @%d: Duplicate Label (%s)!\n", 280 | EC_DL, in_fn[file_level], codeline[file_level], label); 281 | } 282 | 283 | fprintf( stderr, 284 | "*** Error %d in \"%s\" @%d: Duplicate Label (%s)!\n", 285 | EC_DL, in_fn[file_level], codeline[file_level], label); 286 | } 287 | 288 | return (-1); 289 | } 290 | 291 | 292 | /* Now add it to the list. 293 | * *********************** */ 294 | 295 | /* find end of list. 296 | * ----------------- */ 297 | while (Local->next) 298 | Local = (SYMBOL *) Local->next; 299 | 300 | 301 | /* Store symbol name. 302 | * ****************** */ 303 | 304 | /* Allocate memory. 305 | * */ 306 | Local->Symbol_Name = (char *) malloc(strlen(label) + 1); 307 | 308 | /* Check for memory allocation error. 309 | * If no memory allocation error, store the symbol name. 310 | * ----------------------------------------------------- */ 311 | if (Local->Symbol_Name != NULL) 312 | { 313 | strcpy(Local->Symbol_Name, label); 314 | } 315 | /* Can not allocate memory :-( 316 | * --------------------------- */ 317 | else 318 | msg_error_s("Can't allocate memory!", EC_CAM, label); 319 | 320 | 321 | /* Store source file name in which symbol is located. 322 | * ************************************************** */ 323 | 324 | /* Allocate memory. 325 | * */ 326 | Local->src_filename = (char *) malloc(strlen(in_fn[file_level]) + 1); 327 | 328 | /* Check for memory allocation error. 329 | * If no memory allocation error, store the source file name. 330 | * ---------------------------------------------------------- */ 331 | if (Local->src_filename != NULL) 332 | { 333 | strcpy(Local->src_filename, in_fn[file_level]); 334 | } 335 | /* Can not allocate memory :-( 336 | * --------------------------- */ 337 | else 338 | msg_error_s("Can't allocate memory!", EC_CAM, label); 339 | 340 | 341 | /* Store source file line number on which the symbol is located. 342 | * */ 343 | Local->code_line = codeline[file_level]; 344 | 345 | /* - Check for memory allocation error, and display error message 346 | * if necessary. 347 | * - Notes: When not able to allocate memory for new symbol, this 348 | * will make the last symbol in the linked list destroyed next 349 | * time a symbol will be added :-( 350 | * -------------------------------------------------------------- */ 351 | if ((Local->next = (SYMBOL *) calloc(1, sizeof(SYMBOL))) == NULL) 352 | msg_error_s("Can't allocate memory!", EC_CAM, label); 353 | 354 | return (rv); 355 | } 356 | 357 | 358 | /* ************************************************************************* 359 | * Function name: process_label 360 | * Description: Process Label. 361 | * Author(s): Claude Sylvain 362 | * Created: 28 December 2010 363 | * Last modified: 27 December 2011 364 | * 365 | * Parameters: char *label: 366 | * Point to a string that hold label. 367 | * 368 | * Returns: void 369 | * Globals: 370 | * Notes: 371 | * ************************************************************************* */ 372 | 373 | void process_label(char *label) 374 | { 375 | SYMBOL *Local; 376 | 377 | /* If no label, do nothing. 378 | * */ 379 | if (*label == '\0') return; 380 | 381 | /* If in first assembly pass, add and initialize label. 382 | * ---------------------------------------------------- */ 383 | if (asm_pass == 0) 384 | { 385 | /* Add label/name. 386 | * If able to add it, set its value. 387 | * --------------------------------- */ 388 | if (AddLabel(label) != -1) 389 | { 390 | Local = FindLabel(label); 391 | 392 | if (Local != NULL) 393 | { 394 | Local->Symbol_Value = target.pc; 395 | Local->Symbol_Type = SYMBOL_LABEL; 396 | } 397 | } 398 | } 399 | /* We assume we are in second assembler pass... 400 | * Check for phasing error. 401 | * In case there is phasing error, synchronize the label. 402 | * ------------------------------------------------------ */ 403 | else 404 | { 405 | Local = FindLabel(label); 406 | #if 0 407 | if ((Local != NULL) && (Local->Symbol_Value != target.pc)) 408 | { 409 | msg_error_s("Phasing error!", EC_PE, label); 410 | 411 | /* Sync label value. 412 | * ----------------- */ 413 | Local->Symbol_Value = target.pc; 414 | Local->Symbol_Type = SYMBOL_LABEL; 415 | } 416 | #endif 417 | } 418 | } 419 | 420 | 421 | /* ************************************************************************* 422 | * Function name: util_get_number_base_inc 423 | * Description: Get Number Base Increment. 424 | * Author(s): Claude Sylvain 425 | * Created: 23 December 2010 426 | * Last modified: 26 November 2011 427 | * 428 | * Parameters: char *text: 429 | * Text that contain number. 430 | * 431 | * Returns: int: 432 | * Base Increment (2, 8, 10, 16) 433 | * or 434 | * (-1) if an error as occured. 435 | * 436 | * Globals: 437 | * Notes: 438 | * ************************************************************************* */ 439 | 440 | int util_get_number_base_inc(char *text) 441 | { 442 | int rv = -1; 443 | int c_num = 0; 444 | int c; 445 | 446 | 447 | /* Search for the last number character. 448 | * ------------------------------------- */ 449 | while ((*text != '\0') && (isalnum((int) *text) != 0)) 450 | { 451 | text++; 452 | c_num++; /* Keep track of number of characters. */ 453 | } 454 | 455 | /* Process only if a number exist. 456 | * ------------------------------- */ 457 | if (c_num > 0) 458 | { 459 | --text; /* Pos. to last character. */ 460 | c = toupper((int) *text); /* Working copy of last character. */ 461 | 462 | /* - If last character is a decimal digit, this mean that 463 | * the number is a decimal number with no numerical base 464 | * qualifier. 465 | * ------------------------------------------------------- */ 466 | if (isdigit(c)) 467 | { 468 | rv = 10; 469 | } 470 | /* - This is not a number expressed in the default 471 | * decimal base. 472 | * - The last character must be a numerical base 473 | * specifier (B, Q, D, H). 474 | * ----------------------------------------------- */ 475 | else 476 | { 477 | /* - If hold at least 1 digit for the number, 478 | * go further more. 479 | * ------------------------------------------ */ 480 | if (c_num > 1) 481 | { 482 | /* - Replace the numerical base specifier by a delimitor. 483 | * - Notes: This is necessary to avoid the caller 484 | * to have to process that character. 485 | * */ 486 | *text = '\0'; 487 | 488 | /* Set increment, depending on the numerical specifier. 489 | * ---------------------------------------------------- */ 490 | switch(c) 491 | { 492 | case 'B': rv = 2; break; /* Binary base. */ 493 | case 'Q': rv = 8; break; /* Octal base. */ 494 | case 'O': rv = 8; break; /* Octal another way */ 495 | case 'D': rv = 10; break; /* Decimal base. */ 496 | case 'H': rv = 16; break; /* Hexadecimal base. */ 497 | default: rv = 10; break; 498 | } 499 | } 500 | } 501 | } 502 | 503 | return (rv); 504 | } 505 | 506 | 507 | /* ************************************************************************* 508 | * Function name: AdvanceTo 509 | * Description: 510 | * Author(s): Claude Sylvain 511 | * Created: 2007 512 | * Last modified: 27 December 2010 513 | * 514 | * Parameters: char *text: 515 | * ... 516 | * 517 | * char x: 518 | * ... 519 | * 520 | * Returns: char *: 521 | * ... 522 | * 523 | * Globals: 524 | * 525 | * Notes: 526 | * - For DB, and DW, there may be an unbounded list of hex, dec, and octal 527 | * bytes/words, and quoted strings. 528 | * ************************************************************************* */ 529 | 530 | char *AdvanceTo(char *text, char x) 531 | { 532 | while (*text != '\0') 533 | { 534 | if (*text != x) 535 | text++; 536 | else 537 | return (text); 538 | } 539 | 540 | return (text--); 541 | } 542 | 543 | 544 | /* ************************************************************************* 545 | * Function name: AdvancePast 546 | * Description: 547 | * Author(s): Claude Sylvain 548 | * Created: 2007 549 | * Last modified: 23 December 2010 550 | * 551 | * Parameters: char *text: 552 | * ... 553 | * 554 | * char x: 555 | * ... 556 | * 557 | * Returns: char *: 558 | * ... 559 | * 560 | * Globals: 561 | * Notes: 562 | * ************************************************************************* */ 563 | 564 | char *AdvancePast(char *text, char x) 565 | { 566 | text = AdvanceTo(text, x); 567 | return (++text); 568 | } 569 | 570 | 571 | /* ************************************************************************* 572 | * Function name: AdvanceToAscii 573 | * Description: 574 | * Author(s): Claude Sylvain 575 | * Created: 2007 576 | * Last modified: 23 December 2010 577 | * 578 | * Parameters: char *text: 579 | * ... 580 | * 581 | * Returns: char *: 582 | * ... 583 | * 584 | * Globals: 585 | * Notes: 586 | * ************************************************************************* */ 587 | 588 | char *AdvanceToAscii(char *text) 589 | { 590 | /* i.e. not a space. 591 | * ----------------- */ 592 | while (isspace((int) *text)) 593 | text++; 594 | 595 | return (text); 596 | } 597 | 598 | 599 | /* ************************************************************************* 600 | * Function name: AdvanceToAscii 601 | * Description: 602 | * Author(s): Claude Sylvain 603 | * Created: 2007 604 | * Last modified: 23 December 2010 605 | * 606 | * Parameters: char *text: 607 | * ... 608 | * 609 | * Returns: char *: 610 | * ... 611 | * 612 | * Globals: 613 | * Notes: 614 | * ************************************************************************* */ 615 | 616 | char *AdvancePastSpace(char *text) 617 | { 618 | return (AdvanceToAscii(text)); 619 | } 620 | 621 | 622 | /* ************************************************************************* 623 | * Function name: util_is_cs_enable 624 | * Description: Tell if Code Section is Enabled or not. 625 | * Author(s): Claude Sylvain 626 | * Created: 12 February 2011 627 | * Last modified: 628 | * Parameters: void 629 | * 630 | * Returns: int: 631 | * 0 : Code Section innactive. 632 | * 1 : Code Section active. 633 | * 634 | * Globals: int if_true[] 635 | * int if_nest 636 | * 637 | * Notes: 638 | * ************************************************************************* */ 639 | 640 | int util_is_cs_enable(void) 641 | { 642 | int rv = 1; /* Enable (default). */ 643 | int i; 644 | 645 | /* - Search for disabled code section. 646 | * - If disabled code section is found, set return value 647 | * accordingly, and exit loop. 648 | * - Notes: If "if" level is the base level (0), do 649 | * nothing, and exit with 1 (code section enable). 650 | * This is normal, since "if" base level is always 651 | * 1. 652 | * ----------------------------------------------------- */ 653 | for (i = if_nest; i > 0; i--) 654 | { 655 | if (if_true[i] == 0) 656 | { 657 | rv = 0; 658 | break; 659 | } 660 | } 661 | 662 | return (rv); 663 | } 664 | 665 | 666 | /* ************************************************************************* 667 | * Function name: byte_to_hex 668 | * Description: Convert a byte (8-bit data) to an Hexadecimal string. 669 | * Author(s): Claude Sylvain 670 | * Created: 17 December 2011 671 | * Last modified: 672 | * 673 | * Parameters: uint8_t byte: 674 | * 8-bit data to convert to hexadecimal. 675 | * 676 | * char *string: 677 | * - Point to a string that will be filled with 678 | * the hexadecimal representation of "byte". 679 | * - Notes: "string" must have a minimal size 680 | * of 3 bytes (2 digits + string delimitor). 681 | * 682 | * Returns: void 683 | * Globals: 684 | * Notes: 685 | * ************************************************************************* */ 686 | 687 | void byte_to_hex(uint8_t byte, char *string) 688 | { 689 | int i; 690 | uint8_t nibble; 691 | 692 | /* Process all nibbles. 693 | * -------------------- */ 694 | for (i = 1; i >= 0; i--) 695 | { 696 | nibble = byte & 0x0F; /* Get the nibble. */ 697 | 698 | /* Convert and store nibble. 699 | * ------------------------- */ 700 | if (nibble >= 10) 701 | string[i] = (char) (nibble + ('A' - 10)); 702 | else 703 | string[i] = (char) (nibble + '0'); 704 | 705 | byte >>= 4; /* Select next nibble. */ 706 | } 707 | 708 | string[2] = '\0'; /* Add string delimitor. */ 709 | } 710 | 711 | 712 | /* ************************************************************************* 713 | * Function name: word_to_hex 714 | * Description: Convert a word (16-bit data) to an Hexadecimal string. 715 | * Author(s): Claude Sylvain 716 | * Created: 17 December 2011 717 | * Last modified: 718 | * 719 | * Parameters: uint16_t word: 720 | * 16-bit data to convert to hexadecimal. 721 | * 722 | * char *string: 723 | * - Point to a string that will be filled with 724 | * the hexadecimal representation of "word". 725 | * - Notes: "string" must have a minimal size 726 | * of 5 bytes (4 digits + string delimitor). 727 | * 728 | * Returns: void 729 | * Globals: 730 | * Notes: 731 | * ************************************************************************* */ 732 | 733 | void word_to_hex(uint16_t word, char *string) 734 | { 735 | byte_to_hex((uint8_t) (word >> 8), string); 736 | byte_to_hex((uint8_t) (word & 0x00FF), &string[2]); 737 | } 738 | 739 | 740 | 741 | 742 | 743 | 744 | -------------------------------------------------------------------------------- /src/util.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: util.h 3 | * Description: Utilities. 4 | * Copyright(c): See below... 5 | * Author(s): Claude Sylvain 6 | * Created: 23 December 2010 7 | * Last modified: 1 January 2012 8 | * Notes: 9 | * ************************************************************************* */ 10 | 11 | /* 12 | * Copyright (c) <2007-2017> Jay Cotton 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to 16 | * deal in the Software without restriction, including without limitation the 17 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | 34 | /* ************************************************************************* 35 | * ************************************************************************* */ 36 | 37 | #ifndef _UTIL_H 38 | #define _UTIL_H 39 | 40 | 41 | /* ************************************************************************* 42 | * INCLUDE FILES 43 | * ************************************************************************* */ 44 | 45 | #include "project.h" 46 | 47 | 48 | /* ************************************************************************* 49 | * FUNCTIONS DECLARATION 50 | * ************************************************************************* */ 51 | 52 | int islabelchar(int c); 53 | int check_evor(int value, int limit); 54 | int check_oor(int value, int limit); 55 | SYMBOL *FindLabel(char *text); 56 | int AddLabel(char *label); 57 | void process_label(char *label); 58 | int util_get_number_base_inc(char *text); 59 | char *AdvanceTo(char *text, char x); 60 | char *AdvancePast(char *text, char x); 61 | char *AdvanceToAscii(char *text); 62 | char *AdvancePastSpace(char *text); 63 | int util_is_cs_enable(void); 64 | void byte_to_hex(uint8_t byte, char *string); 65 | void word_to_hex(uint16_t word, char *string); 66 | 67 | 68 | #endif 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/war_code.h: -------------------------------------------------------------------------------- 1 | /* ************************************************************************* 2 | * Module Name: war_code.h 3 | * Description: Assembler Warning Codes. 4 | * Copyright(c): See below... 5 | * Author(s): Claude Sylvain 6 | * Created: 23 December 2010 7 | * Last modified: 17 May 2013 8 | * Notes: 9 | * ************************************************************************* */ 10 | 11 | /* 12 | * Copyright (c) <2007-2017> Jay Cotton 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to 16 | * deal in the Software without restriction, including without limitation the 17 | * rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | 34 | /* ************************************************************************* 35 | * ************************************************************************* */ 36 | 37 | #ifndef _WAR_CODE_H 38 | #define _WAR_CODE_H 39 | 40 | 41 | /* ************************************************************************* 42 | * CONSTANTS 43 | * ************************************************************************* */ 44 | 45 | #define WC_MQ 0 /* Missing Quote. */ 46 | #define WC_EDFIIF 1 /* 'END' Directive Found Inside an Include File. */ 47 | #define WC_ELOS 2 /* Extra "-l" Option Specified. */ 48 | #define WC_EOOS 3 /* Extra "-o" Option Specified. */ 49 | #define WC_NIFSATLOP 4 /* No Input File Specified At Time "-l" Option was Processed. */ 50 | #define WC_NIFSATOOP 5 /* No Input File Specified At Time "-o" Option was Processed. */ 51 | #define WC_OFNHE 6 /* Output File Name Have an Extension. */ 52 | #define WC_LNBFC 7 /* Label/Name, Bad First Character. */ 53 | #define WC_SCNS 8 /* Special Command Not Supported. */ 54 | #define WC_LTL 9 /* Label Too Long. */ 55 | #define WC_ILNC 10 /* Invalid Label/Name Character. */ 56 | #define WC_IFNHNE 11 /* Input File Name Have No Extension. */ 57 | #define WC_SAUAL 12 /* Symbol Already Used As Label. */ 58 | #define WC_MPNS 13 /* Macro Parameters Not Supported. */ 59 | #define WC_IDERINB 14 /* "IF" Directive Expression Result Is Not Boolean. */ 60 | 61 | 62 | 63 | #endif 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /test/b_tbl.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ;****************************************************************************** 4 | 5 | 6 | DUMMY equ 0 7 | 8 | 9 | ; org 0000H 10 | 11 | 12 | start: lxi h, btbl ;Registers H and L will 13 | ;Point to branch table. 14 | 15 | gtbit: rar 16 | jc getad 17 | inx h 18 | inx h 19 | 20 | jmp gtbit 21 | ; jmp toto 22 | getad: mov e, m 23 | inx h 24 | 25 | mov d, m 26 | xchg 27 | 28 | pchl 29 | 30 | 31 | 32 | btbl: dw rout1 33 | dw rout2 34 | dw rout3 35 | dw rout4 36 | dw rout5 37 | dw rout6 38 | dw rout7 39 | dw rout8 40 | 41 | 42 | 43 | rout1: 44 | rout2: 45 | rout3: 46 | rout4: 47 | rout5: 48 | rout6: 49 | rout7: 50 | rout8: 51 | jmp start 52 | 53 | 54 | 55 | 56 | ; end 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /test/div.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ;- Ref.: 8080-8085_assembly_language_programming__1977__intel__pdf_.pdf, 4 | ; page 178. 5 | 6 | 7 | div 8 | mov a, d 9 | cma 10 | mov d, a 11 | mov a, e 12 | cma 13 | mov e, a 14 | inx d 15 | lxi h, 0 16 | mvi a, 17 17 | 18 | div_00 19 | push h 20 | dad d 21 | jnc div_01 22 | 23 | xthl 24 | 25 | div_01 26 | pop h 27 | push psw 28 | mov a, c 29 | ral 30 | mov c, a 31 | mov a, b 32 | ral 33 | mov b, a 34 | mov a, l 35 | ral 36 | mov l, a 37 | mov a, h 38 | ral 39 | mov h, a 40 | pop psw 41 | dcr a 42 | jnz div_00 43 | 44 | ;Post-divide clean up. 45 | ;Shift remainder right and return in DE. 46 | 47 | ora a 48 | mov a, h 49 | rar 50 | mov d, a 51 | mov a, l 52 | rar 53 | mov e, a 54 | 55 | ret 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /test/dsub.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ;- Ref.: 8080-8085_assembly_language_programming__1977__intel__pdf_.pdf, 4 | ; page 185. 5 | 6 | 7 | dsub_minu_start ds 8 8 | dsub_minu: equ $ - 1 9 | 10 | dsub_sbtra_start ds 8 11 | dsub_sbtra equ $ - 1 12 | 13 | 14 | dsub 15 | lxi d, dsub_minu 16 | lxi h, dsub_sbtra 17 | mvi c, 8 18 | stc 19 | 20 | dsub_00 21 | mvi a, 99H 22 | aci 0 23 | sub m 24 | xchg 25 | add m 26 | daa 27 | mov m, a 28 | xchg 29 | dcr c 30 | jz dsub_01 31 | 32 | inx d 33 | inx h 34 | jmp dsub_00 35 | 36 | dsub_01 37 | nop 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /test/jos.asm: -------------------------------------------------------------------------------- 1 | ; test cases from jos 2 | NOP 3 | NOP 4 | NOP 5 | LBL 6 | ORG 0100H ;LBL should have value 3 7 | NOP 8 | LXI B,LBL 9 | NOP 10 | ; 11 | ; 12 | ; Intel 8080-8085 Assembly Language Programming 1977. 13 | ; 14 | ; Page 2.5 15 | 16 | HERE: MVI C,0BAH 17 | ABC: MVI E,15 18 | MVI E,15D 19 | LABEL: MVI A,72Q 20 | NOW: MVI D,11110110B 21 | JOS: MVI A,72O 22 | JOS1: lxi h,177777O 23 | 24 | DATE: DB 'TODAY','S DATE' 25 | ; this on is added for my interest 26 | ; 27 | XYZZY:: DB 0 ; 28 | 29 | ; 30 | ; Intel 8080-8085 Assembly Language Programming 1977. 31 | ; 32 | ; Page 2.12 33 | ; 34 | 35 | ; All should generate 65D/41H 36 | ; NOTE. asm8080 is not good at expression hierarchy so, brase boys brase. 37 | MVI B, 5+(30*2) ; force presidence 38 | MVI B, (25/5)+(30*2) ; force presidence 39 | MVI B, 5+((-30)*(-2)) ; needed or it thinks its a subtract. 40 | MVI B, (25 MOD 8) + 64 41 | 42 | ;;;;;; 43 | 44 | NUM1 EQU 00010001B 45 | NUM2 EQU 00010000B 46 | DB NOT NUM1 47 | DB NUM1 AND NUM2 48 | DB NUM1 AND NUM1 49 | DB NUM1 OR NUM2 50 | DB NUM2 OR NUM2 51 | DB NUM1 XOR NUM2 52 | DB NUM1 XOR NUM1 53 | DB 5 EQ 5 54 | DB 5 NE 5 55 | DB 5 GT 4 56 | DB 4 GE 5 57 | DB 4 LT 5 58 | DB 4 LE 5 59 | 60 | end 61 | -------------------------------------------------------------------------------- /test/madd.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ;- Ref.: 8080-8085_assembly_language_programming__1977__intel__pdf_.pdf, 4 | ; page 180. 5 | 6 | 7 | madd: 8 | lxi b, madd_02 9 | lxi h, madd_03 10 | xra a 11 | 12 | madd_00: 13 | ldax b 14 | adc m 15 | stax b 16 | dcr e 17 | jz madd_01 18 | 19 | inx b 20 | inx h 21 | jmp madd_00 22 | madd_01: 23 | 24 | 25 | madd_02: 26 | db 90H 27 | db 0BAH 28 | db 84H 29 | 30 | madd_03: 31 | db 8AH 32 | db 0AFH 33 | db 32H 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/main.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | org 0000H 4 | 5 | 6 | ; include "b_tbl.asm" 7 | include b_tbl.asm 8 | 9 | include "mult.asm" 10 | include "div.asm" 11 | include "madd.asm" 12 | include "dsub.asm" 13 | 14 | 15 | end 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/mult.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ;- Ref.: 8080-8085_assembly_language_programming__1977__intel__pdf_.pdf, 4 | ; page 177. 5 | 6 | 7 | mult: mvi b, 0 8 | mvi e, 9 9 | 10 | mult_00: 11 | mov a, c 12 | rar 13 | mov c, a 14 | dcr e 15 | jz mult_end 16 | mov a, b 17 | jnc mult_01 18 | add d 19 | 20 | mult_01: 21 | rar 22 | mov b, a 23 | jmp mult_00 24 | 25 | mult_end: 26 | ret 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /test/test.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ; 4 | ;Copyright (c) <2007-2011> 5 | ; 6 | ;Permission is hereby granted, free of charge, to any person 7 | ;obtaining a copy of this software and associated documentation 8 | ;files (the "Software"), to deal in the Software without 9 | ;restriction, including without limitation the rights to use, 10 | ;copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ;copies of the Software, and to permit persons to whom the 12 | ;Software is furnished to do so, subject to the following 13 | ;conditions: 14 | ; 15 | ;The above copyright notice and this permission notice shall be 16 | ;included in all copies or substantial portions of the Software. 17 | ; 18 | ;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | ;EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | ;OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | ;NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | ;HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | ;WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | ;FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | ;OTHER DEALINGS IN THE SOFTWARE. 26 | ; 27 | 28 | 29 | ; test file 30 | 31 | 32 | ;$include "macro.asm" 33 | 34 | 35 | true equ 1 36 | false equ 0 37 | 38 | 39 | if true 40 | lxi h,end 41 | endif 42 | 43 | if false 44 | lxi h,end1 45 | endif 46 | 47 | 48 | start EQU $ 49 | ; 50 | end equ $ 51 | end1 equ $ 52 | 53 | 54 | ; org 0x420 55 | org 0420h 56 | 57 | 58 | LIST equ $ 59 | 60 | 61 | ; db (LIST > 8) + 128 , LIST and 0xff 62 | db (LIST > 8) + 128 , LIST and 0FFh 63 | 64 | 65 | END 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /test/test1.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ; 4 | ;Copyright (c) <2007-2011> 5 | ; 6 | ;Permission is hereby granted, free of charge, to any person 7 | ;obtaining a copy of this software and associated documentation 8 | ;files (the "Software"), to deal in the Software without 9 | ;restriction, including without limitation the rights to use, 10 | ;copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | ;copies of the Software, and to permit persons to whom the 12 | ;Software is furnished to do so, subject to the following 13 | ;conditions: 14 | ; 15 | ;The above copyright notice and this permission notice shall be 16 | ;included in all copies or substantial portions of the Software. 17 | ; 18 | ;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | ;EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | ;OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | ;NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | ;HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | ;WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | ;FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | ;OTHER DEALINGS IN THE SOFTWARE. 26 | ; 27 | 28 | 29 | ; Test file used to checkout the assembler 30 | 31 | 32 | ;- Not standard, but supported if asm8080 is build with 33 | ; support for language extension. 34 | ; 35 | DB "Test Test Test" 36 | 37 | DB 'Test Test Test' 38 | 39 | 40 | FRONT EQU $ 41 | BACK EQU FRONT 42 | XYZ EQU 7 43 | 44 | 45 | TEST MOV A,B 46 | TES1 MOV A,C 47 | 48 | ;This should load HL with a value of 000Dh. 49 | ; 50 | LXI HL,((XYZ + 20)+TEST)/4 51 | 52 | MOV A,D 53 | MOV A,E 54 | MOV A,H 55 | MOV A,L 56 | MOV A,M 57 | MOV B,A 58 | MOV B,C 59 | MOV B,D 60 | MOV B,E 61 | MOV B,H 62 | MOV B,L 63 | MOV B,M 64 | MOV C,A 65 | MOV C,B 66 | MOV C,D 67 | MOV C,E 68 | MOV C,H 69 | MOV C,L 70 | MOV C,M 71 | MOV D,A 72 | MOV D,B 73 | MOV D,C 74 | MOV D,E 75 | MOV D,H 76 | MOV D,L 77 | MOV D,M 78 | MOV E,A 79 | MOV E,B 80 | MOV E,C 81 | MOV E,D 82 | MOV E,H 83 | MOV E,L 84 | MOV E,M 85 | MOV H,A 86 | MOV H,B 87 | MOV H,C 88 | MOV H,D 89 | MOV H,E 90 | MOV H,L 91 | MOV H,M 92 | MOV L,A 93 | MOV L,B 94 | MOV L,C 95 | MOV L,D 96 | MOV L,E 97 | MOV L,H 98 | MOV L,M 99 | MOV M,A 100 | MOV M,B 101 | MOV M,C 102 | MOV M,D 103 | MOV M,E 104 | MOV M,H 105 | MOV M,L 106 | TEST2 MVI A,25 107 | MVI B,2 108 | MVI C,2 109 | TEST4 MVI D,2 110 | MVI D,'T' 111 | MVI D,XYZ 112 | MVI E,2 113 | MVI H,2 114 | MVI L,2 115 | MVI M,2 116 | ;TEST3 LXI BC,0x2233 117 | TEST3 LXI BC,2233h 118 | ; LXI DE,0x2233 119 | LXI DE,2233h 120 | ; LXI HL,0x2233 121 | LXI HL,2233h 122 | ; LXI SP,0x2233 123 | LXI SP,2233h 124 | LXI SP,TEST4 125 | ; LXI SP,"DF" 126 | ; LDA 0x1234 127 | LDA 1234h 128 | LDA TEST3 129 | ; LDA "xyay" 130 | LDA 'l' 131 | LDA $ 132 | LDA $+8 133 | LDA $-8 134 | LDA $+'T' 135 | LDA $+TEST3 136 | LDA $-TEST3 137 | ; STA 0x1234 138 | STA 1234h 139 | STA TEST3 140 | ; STA "xyay" 141 | STA 'l' 142 | STA $ 143 | STA $+8 144 | STA $-8 145 | STA $+'T' 146 | STA $+TEST3 147 | STA $-TEST3 148 | ; LHLD 0x1234 149 | LHLD 1234h 150 | LHLD TEST3 151 | ; LHLD "xyay" 152 | LHLD 'l' 153 | LHLD $ 154 | LHLD $+8 155 | LHLD $-8 156 | LHLD $+'T' 157 | LHLD $+TEST3 158 | LHLD $-TEST3 159 | ; SHLD 0x1234 160 | SHLD 1234h 161 | SHLD TEST3 162 | ; SHLD "xyay" 163 | SHLD 'l' 164 | SHLD $ 165 | SHLD $+8 166 | SHLD $-8 167 | SHLD $+'T' 168 | SHLD $+TEST3 169 | SHLD $-TEST3 170 | LDAX BC 171 | LDAX DE 172 | STAX BC 173 | STAX DE 174 | XCHG 175 | ADD A 176 | ADD B 177 | ADD C 178 | ADD D 179 | ADD E 180 | ADD H 181 | ADD L 182 | ADD M 183 | ADI low $ 184 | ADI 4 185 | ; ADI 0x45 186 | ADI 45h 187 | ADI 'T' 188 | ADI XYZ 189 | ADC A 190 | ADC B 191 | ADC C 192 | ADC D 193 | ADC E 194 | ADC H 195 | ADC L 196 | ADC M 197 | ; ACI $ 198 | ACI 4 199 | ; ACI 0x45 200 | ACI 45h 201 | ACI 'T' 202 | ACI XYZ 203 | SUB A 204 | SUB B 205 | SUB C 206 | SUB D 207 | SUB E 208 | SUB H 209 | SUB L 210 | SUB M 211 | SUI low $ 212 | SUI 4 213 | ; SUI 0x45 214 | SUI 45h 215 | SUI 'T' 216 | SUI XYZ 217 | SBB A 218 | SBB B 219 | SBB C 220 | SBB D 221 | SBB E 222 | SBB H 223 | SBB L 224 | SBB M 225 | SBI high $ 226 | SBI 4 227 | ; SBI 0x45 228 | SBI 45h 229 | SBI 'T' 230 | SBI XYZ 231 | INR A 232 | INR B 233 | INR C 234 | INR D 235 | INR E 236 | INR H 237 | INR L 238 | INR M 239 | DCR A 240 | DCR B 241 | DCR C 242 | DCR D 243 | DCR E 244 | DCR H 245 | DCR L 246 | DCR M 247 | INX BC 248 | INX HL 249 | INX DE 250 | INX SP 251 | DCX BC 252 | DCX HL 253 | DCX DE 254 | DCX SP 255 | DAD BC 256 | DAD HL 257 | DAD DE 258 | DAD SP 259 | DAA 260 | ANA A 261 | ANA B 262 | ANA C 263 | ANA D 264 | ANA E 265 | ANA H 266 | ANA L 267 | ANA M 268 | ANI low $ 269 | ANI 4 270 | ; ANI 0x45 271 | ANI 45h 272 | ANI 'T' 273 | ANI XYZ 274 | ORA A 275 | ORA B 276 | ORA C 277 | ORA D 278 | ORA E 279 | ORA H 280 | ORA L 281 | ORA M 282 | XRA A 283 | XRA B 284 | XRA C 285 | XRA D 286 | XRA E 287 | XRA H 288 | XRA L 289 | XRA M 290 | XRI high $ 291 | XRI 4 292 | ; XRI 0x45 293 | XRI 45h 294 | XRI 'T' 295 | XRI XYZ 296 | CMP A 297 | CMP B 298 | CMP C 299 | CMP D 300 | CMP E 301 | CMP H 302 | CMP L 303 | CMP M 304 | CPI low $ 305 | CPI 4 306 | ; CPI 0x45 307 | CPI 45h 308 | CPI 'T' 309 | CPI XYZ 310 | RLC 311 | RRC 312 | RAL 313 | RAR 314 | CMA 315 | CMC 316 | STC 317 | ; JMP 0x1234 318 | JMP 1234h 319 | JMP TEST3 320 | ; JMP "xyay" 321 | JMP 'l' 322 | JMP $ 323 | JMP $+8 324 | JMP $-8 325 | JMP $+'T' 326 | JMP $+TEST3 327 | JMP $-TEST3 328 | ; JNZ 0x1234 329 | JNZ 1234h 330 | JZ TEST3 331 | ; JNC "xyay" 332 | JC 'l' 333 | JPO $ 334 | JPE $+8 335 | JP $-8 336 | JM $+'T' 337 | ; CALL 0x1234 338 | CALL 1234h 339 | CALL TEST3 340 | ; CALL "xyay" 341 | CALL 'l' 342 | CALL $ 343 | CALL $+8 344 | CALL $-8 345 | CALL $+'T' 346 | CALL $+TEST3 347 | ; CNZ 0x1234 348 | CNZ 1234h 349 | CZ TEST3 350 | ; CNC "xyay" 351 | CC 'l' 352 | CPO $ 353 | CPE $+8 354 | CP $-8 355 | CM $+'T' 356 | RET 357 | RNZ 358 | RZ 359 | RNC 360 | RC 361 | RPO 362 | RPE 363 | RP 364 | RM 365 | ; RST 0x1234 366 | RST 7h 367 | ; RST TEST3 368 | RST XYZ 369 | ; RST "xyay" 370 | ; RST 'l' 371 | ; RST $ 372 | ; RST $+8 373 | ; RST $-8 374 | ; RST $+'T' 375 | PCHL 376 | PUSH DE 377 | PUSH BC 378 | PUSH HL 379 | PUSH PSW 380 | POP DE 381 | POP BC 382 | POP HL 383 | POP PSW 384 | XTHL 385 | SPHL 386 | ; IN 0x1234 387 | IN low 1234h 388 | IN TEST3 389 | ; IN "xyay" 390 | IN 'l' 391 | IN low $ 392 | IN low ($+8) 393 | IN high ($-8) 394 | IN low ($+'T') 395 | ; OUT 0x1234 396 | OUT high 1234h 397 | OUT TEST3 398 | ; OUT "xyay" 399 | OUT 'l' 400 | OUT low $ 401 | OUT high ($+8) 402 | OUT low ($-8) 403 | OUT high ($+'T') 404 | EI 405 | DI 406 | HLT 407 | NOP 408 | 409 | 410 | END 411 | 412 | 413 | 414 | -------------------------------------------------------------------------------- /test/test_comment.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | org 0 6 | 7 | 8 | push b ;Comment. 9 | pop b ;Comment 10 | 11 | mov a, b ;Comment 12 | 13 | 14 | 15 | end 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/test_db_1.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | label_1 6 | nop 7 | 8 | label_2 9 | nop 10 | 11 | 12 | db label_2 - label_1 13 | db label_2-label_1 14 | db label_2 - label_1, label_2 - label_1 15 | db label_2-label_1,label_2-label_1 16 | db "Hello!" 17 | db "Hello!", "Hello!" 18 | db "Hello!", "Hello!", label_2 - label_1 19 | db "Hello!","Hello!",label_2-label_1 20 | label_3 21 | db "Hello!","Hello!",label_2-label_1 22 | label_4: 23 | db "Hello!","Hello!",label_2-label_1 24 | label5 25 | db "Hello!","Hello!",label_2-label_1 26 | db $, 1 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/test_dw_1.asm: -------------------------------------------------------------------------------- 1 | ;****************************************************************************** 2 | ;Filename: test_dw_1.asm 3 | ;Description: "DW" assembler directive test. 4 | ;Copyright(c): 5 | ;Author(s): Claude Sylvain 6 | ;Created: December 2010 7 | ;Last modified: 6 January 2012 8 | ;****************************************************************************** 9 | 10 | 11 | label_1 12 | nop 13 | 14 | label_2 15 | nop 16 | 17 | 18 | dw label_2 19 | dw label_2 - label_1 20 | dw label_2-label_1 21 | dw label_2 - label_1, label_2 - label_1 22 | dw label_2-label_1,label_2-label_1 23 | 24 | ;Each characters pair must appear as a Little Endian word. 25 | ;--------------------------------------------------------- 26 | dw 'ABCD' 27 | dw "ABCD" 28 | 29 | ;Single character must appear as LSB on a Little Endian word. 30 | ;------------------------------------------------------------ 31 | dw 'A' 32 | dw "A" 33 | dw 'ABC' 34 | dw "ABC" 35 | 36 | dw "Hello!" 37 | dw "Hello!", "Hello!" 38 | dw "Hello!", "Hello!", label_2 - label_1 39 | dw "Hello!","Hello!",label_2-label_1 40 | label_3 41 | dw "Hello!","Hello!",label_2-label_1 42 | label_4: 43 | dw "Hello!","Hello!",label_2-label_1 44 | label5 45 | dw "Hello!","Hello!",label_2-label_1 46 | dw $, 1 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /test/test_ee.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | TEST_1 equ 1 5 | TEST_2 equ TEST_1 6 | 7 | 8 | 9 | org 0 10 | 11 | 12 | 13 | ; lxi TEST_2 14 | ; lxi b, TEST_2 15 | ; lxi 1 16 | lxi b, 0FFFFFH ;Operand over range. 17 | 18 | 19 | 20 | 21 | end 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /test/test_ep_1.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ; cpi 'Z' + 1 6 | cpi ('Z' + 1) 7 | 8 | adi 'Z' + 1 9 | aci 'Z' + 1 10 | sui 'Z' + 1 11 | sbi 'Z' + 1 12 | ani 'Z' + 1 13 | xri 'Z' + 1 14 | ori 'Z' + 1 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/test_ep_2.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mvi a, (1 / 1) 6 | lxi b, (1 / 1) 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/test_ep_3.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TOP_MEMORY equ 0800h 6 | 7 | 8 | 9 | ; lxi sp, (TOP_MEMORY + 1) 10 | lxi sp, TOP_MEMORY + 1 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/test_ep_4.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | org 0100h 4 | 5 | 6 | start 7 | mvi a, start / 256 8 | mvi a, start >> 8 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/test_ep_5.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | org 1234h 4 | 5 | 6 | start 7 | 8 | if 1 9 | 10 | ; mvi a, LOW(start) 11 | mvi a, start and 0FFh 12 | 13 | ; mvi a, HIGH(start) 14 | mvi a, start >> 8 15 | mvi a, start / 256 16 | 17 | ; mvi a, NOT(LOW(start)) 18 | mvi a, 0FFh - (start and 00FFh) 19 | 20 | ; mvi a, LOW((NOT)start) 21 | mvi a, (0FFFFh - start) and 0FFh 22 | 23 | endif 24 | 25 | ; mvi a, NOT(HIGH(start)) 26 | mvi a, 0FFh - (start >> 8) 27 | mvi a, 0FFh - (start / 256) 28 | mvi a, 0FFh - (1234h / 256) 29 | 30 | ; mvi a, HIGH((NOT)start) 31 | mvi a, (0FFFFh - start) >> 8 32 | mvi a, (0FFFFh - start) / 256 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /test/test_equ.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | if 0 4 | 5 | EQU_TEST1 equ 0 6 | EQU_TEST2 equ "Hello!" ;"EQU" do not support string. 7 | EQU_TEST3 equ '6' 8 | EQU_TEST4 equ 2+2 9 | 10 | ;"EQU" work with value between 0 and 65535. 11 | ; 12 | EQU_TEST5 equ 0FFFFFH 13 | 14 | EQU_TEST6 equ EQU_TEST4 + 1 15 | EQU_TEST7 equ EQU_TEST4+1 16 | EQU_TEST8 equ (EQU_TEST4 + 1) 17 | EQU_TEST9 equ (EQU_TEST4+1) 18 | EQU_TEST10 equ ((EQU_TEST4 + 1)) 19 | EQU_TEST11 equ ((EQU_TEST4 + 1)) 20 | EQU_TEST12 equ ((EQU_TEST4 + 1)) 21 | 22 | EQU_TEST13 equ ((EQU_TEST4 + '0')) 23 | 24 | EQU_TEST14 equ 0AAh + 03h 25 | EQU_TEST14a equ 0AAH + 03H 26 | EQU_TEST15 equ 0AAh+03h 27 | EQU_TEST16 equ 0AAh * 03h 28 | 29 | 30 | EQU_TEST17 equ (0AAh * 03h) + 1 31 | 32 | EQU_TEST18 equ 1d 33 | EQU_TEST19 equ 000000001d 34 | 35 | endif 36 | 37 | 38 | if 0 39 | 40 | EQU_TEST20 equ -1 41 | EQU_TEST21 equ -1-1 42 | ;EQU_TEST21 equ (-1)-1 43 | EQU_TEST22 equ -1-1+1 44 | ;EQU_TEST22 equ ((-1)-1)+1 45 | EQU_TEST23 equ -1-1+3 46 | ;EQU_TEST23 equ ((-1)-1)+3 47 | 48 | EQU_TEST24 equ EQU_TEST4+EQU_TEST4 49 | EQU_TEST25 equ EQU_TEST4+EQU_TEST4+EQU_TEST4 50 | EQU_TEST26 equ EQU_TEST4 + EQU_TEST4 + EQU_TEST4 51 | EQU_TEST27 equ (EQU_TEST4 + EQU_TEST4) + EQU_TEST4 52 | EQU_TEST28 EQU (EQU_TEST4 + EQU_TEST4) + EQU_TEST4 53 | 54 | EQU_TEST29 EQU ((EQU_TEST4 + EQU_TEST4) + EQU_TEST4) * 2 55 | EQU_TEST30 EQU (((EQU_TEST4 + EQU_TEST4) + EQU_TEST4) * 2) / 3 56 | 57 | endif 58 | 59 | 60 | 61 | ;my_symbol set 10 62 | my_symbol equ 11 63 | ;my_symbol set 12 64 | my_symbol equ 12 65 | ;my_symbol set 11 66 | ;my_symbol set 12 67 | ;my_symbol set 13 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /test/test_high.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | if 0 5 | _HIGH equ start / 256 6 | _LOW equ start & 0FFh 7 | endif 8 | 9 | 10 | org 0 11 | 12 | 13 | ds 258 14 | 15 | 16 | start 17 | 18 | _HIGH equ start / 256 19 | _LOW equ start & 0FFh 20 | 21 | ; mvi a, start 22 | ; mvi a, start >> 8 23 | ; mvi a, (start >> 8) 24 | ; mvi a, (start / 256) 25 | mvi a, start / 256 26 | ; mvi a, (1 / 1) 27 | mvi a, _LOW 28 | mvi a, _HIGH 29 | 30 | 31 | 32 | end 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /test/test_if.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ;12 February 2011 4 | ;Test/Debug the following error: 5 | ; *** Error 6 in "test_if.asm": 'if' nesting underflow! 6 | ;************************************************************ 7 | 8 | if 0 9 | 10 | if 0 11 | nop 12 | endif 13 | 14 | else 15 | 16 | nop 17 | 18 | endif 19 | 20 | 21 | ;Additionnal tests. 22 | ;****************** 23 | 24 | if 1 25 | 26 | if 0 27 | nop 28 | endif 29 | 30 | else 31 | 32 | nop 33 | 34 | endif 35 | 36 | 37 | if 0 38 | 39 | if 1 40 | nop 41 | endif 42 | 43 | else 44 | 45 | nop 46 | 47 | endif 48 | 49 | 50 | if 1 51 | 52 | if 1 53 | nop 54 | endif 55 | 56 | else 57 | 58 | nop 59 | 60 | endif 61 | 62 | 63 | if 1 64 | 65 | if 0 66 | nop 67 | else 68 | nop 69 | endif 70 | 71 | else 72 | 73 | nop 74 | 75 | endif 76 | 77 | 78 | ;****************************************************************************** 79 | ;Date: 9 May 2013 80 | ;****************************************************************************** 81 | 82 | ;- Test for the following standard: 83 | ; - Logical operators (NOT, AND, OR, XOR) use only bit 0 of 84 | ; value. 85 | ; If this is not the case, the assembler display a warning 86 | ; message. 87 | ;**************************************************************** 88 | 89 | CONDITION_1 equ 1 90 | CONDITION_2 equ 2 91 | CONDITION_3 equ 3 92 | 93 | 94 | if 2 95 | nop 96 | endif 97 | 98 | if CONDITION_1 99 | nop 100 | endif 101 | 102 | if not CONDITION_1 103 | nop 104 | endif 105 | 106 | if not CONDITION_2 107 | nop 108 | endif 109 | 110 | if CONDITION_2 and CONDITION_3 111 | nop 112 | endif 113 | 114 | if CONDITION_2 or CONDITION_3 115 | nop 116 | endif 117 | 118 | if CONDITION_2 xor CONDITION_3 119 | nop 120 | endif 121 | 122 | 123 | ;****************************************************************************** 124 | ;****************************************************************************** 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /test/test_include.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ; include ../src/test/empty.asm 4 | ; include ../src/test/empty.asm ;This is a comment. 5 | ; include "../src/test/empty.asm" ;This is a comment. 6 | ; include ../src/test/empty.asm 7 | ; include "../src/test/empty.asm" 8 | include "empty.asm" 9 | include empty2.asm 10 | include empty3.asm ;This is a comment. 11 | 12 | ;- Include that file to test for ""END" directive found inside an 13 | ; include file!" Warning. 14 | ; 15 | ; include empty4.asm 16 | 17 | 18 | org 0FFFEh 19 | 20 | 21 | main 22 | This_is_a_long_one 23 | 24 | 25 | mov a, b 26 | 27 | 28 | end 29 | 30 | 31 | 32 | lxi 0 33 | mov b, a 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/test_jmp.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | here 7 | ; jmp here 8 | jmp "here" 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/test_listing.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | include test_listing2.asm 4 | 5 | 6 | if 0 7 | mvi a, 0 8 | endif 9 | 10 | 11 | nop 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/test_listing2.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | if 0 4 | lxi h, 0 5 | endif 6 | 7 | 8 | mov b, a 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/test_macro.asm: -------------------------------------------------------------------------------- 1 | ;****************************************************************************** 2 | ;Filename: test_macro.asm 3 | ;Description: Assembly module to test asm8080 "MACRO" assembly directive. 4 | ;Copyright(c): 5 | ;Author(s): Claude Sylvain 6 | ;Created: 28 December 2011 7 | ;Last modified: 29 December 2011 8 | ;****************************************************************************** 9 | 10 | 11 | ;****************************************************************************** 12 | ;****************************************************************************** 13 | 14 | ;Empty macro. 15 | ;------------ 16 | M_EMPTY macro 17 | endm 18 | 19 | 20 | ;NOP3 macro x 21 | NOP3 macro 22 | 23 | nop 24 | nop 25 | nop 26 | 27 | endm 28 | 29 | 30 | CLRA macro 31 | if 0 32 | mvi a, 0 33 | endif 34 | xra a 35 | endm 36 | 37 | 38 | TSTA macro 39 | ora a 40 | endm 41 | 42 | 43 | ;****************************************************************************** 44 | ;Macro name: DELAY_1 45 | ;Description: 46 | ;Created: 28 December 2011 47 | ;Last modified: 29 December 2011 48 | ;****************************************************************************** 49 | 50 | DELAY_1 macro 51 | 52 | ; xra a 53 | CLRA 54 | 55 | delay_1_00 56 | dcr a 57 | jnz delay_1_00 ;Loop if delay not ended. 58 | 59 | endm 60 | 61 | 62 | ;****************************************************************************** 63 | ;****************************************************************************** 64 | 65 | mvi a, 0 66 | 67 | 68 | NOP3 69 | CLRA 70 | TSTA 71 | DELAY_1 72 | M_EMPTY 73 | 74 | 75 | ;****************************************************************************** 76 | ;****************************************************************************** 77 | 78 | db 0, 1 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /test/test_not.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | MY_SYMBOL equ 1 4 | 5 | 6 | if not MY_SYMBOL 7 | nop 8 | endif 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/test_opcode_in.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org 0 5 | 6 | 7 | 8 | in 0 9 | in 0AAH 10 | in 0FFH 11 | in 0FFFFH ;Operand over range. 12 | 13 | 14 | 15 | 16 | 17 | end 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/test_operator.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | FALSE equ 0 4 | TRUE equ 1 5 | 6 | 7 | db high 1234h 8 | db low 1234h 9 | 10 | db 15 mod 2 11 | 12 | ;- '%' is a special character, and can not be 13 | ; implemented as a "C" like operator :-( 14 | ;-------------------------------------------- 15 | if 0 16 | db 15 % 2 17 | endif 18 | 19 | db 1 SHL 1 20 | db 1 SHL 2 21 | 22 | db 1 << 1 23 | db 1 << 2 24 | 25 | db 10000000b SHR 1 26 | db 10000000b SHR 2 27 | 28 | db 10000000b >> 1 29 | db 10000000b >> 2 30 | 31 | db +1 32 | db 1+1 33 | 34 | db -1 35 | db 2-1 36 | 37 | db 2 EQ 1 38 | db 1 EQ 1 39 | 40 | db 2 == 1 41 | db 1 == 1 42 | 43 | db 2 = 1 44 | db 1 = 1 45 | 46 | db 1 LT 1 47 | db 1 LT 2 48 | 49 | db 1 < 1 50 | db 1 < 2 51 | 52 | db 1 LE 0 53 | db 1 LE 1 54 | db 1 LE 2 55 | 56 | db 1 <= 0 57 | db 1 <= 1 58 | db 1 <= 2 59 | 60 | db 1 GT 1 61 | db 1 GT 0 62 | 63 | db 1 > 1 64 | db 1 > 0 65 | 66 | db 1 GE 2 67 | db 1 GE 0 68 | db 1 GE 1 69 | db 2 GE 1 70 | 71 | db 1 >= 2 72 | db 1 >= 0 73 | db 1 >= 1 74 | db 2 >= 1 75 | 76 | db 2 NE 1 77 | db 1 NE 1 78 | 79 | ;- '!' is a special character, and can not be 80 | ; implemented as a "C" like operator :-( 81 | ;-------------------------------------------- 82 | if 0 83 | db 2 != 1 84 | db 1 != 1 85 | endif 86 | 87 | db not 0 88 | dw not 0 89 | db not 0FFh 90 | dw not 0FFh 91 | db not 0FFFFh 92 | dw not 0FFFFh 93 | 94 | ;- '!' is a special character, and can not be 95 | ; implemented as a "C" like operator :-( 96 | ;-------------------------------------------- 97 | if 0 98 | db !0 99 | db !0FFh 100 | db !0FFFFh 101 | endif 102 | 103 | ;No more supported (2013-04-27). 104 | ;------------------------------- 105 | if 0 106 | db ~0 107 | dw ~0 108 | db ~0FFh 109 | dw ~0FFh 110 | db ~0FFFFh 111 | dw ~0FFFFh 112 | endif 113 | 114 | db 0FFFFh and 5555h 115 | dw 0FFFFh and 5555h 116 | db 0 or 0AAAAh 117 | dw 0 or 0AAAAh 118 | db 0AAAAh xor 0AAAAh 119 | dw 0AAAAh xor 0AAAAh 120 | 121 | ;- '&' is a special character, and can not be 122 | ; implemented as a "C" like operator :-( 123 | ;-------------------------------------------- 124 | if 0 125 | db 0FFFFh & 5555h 126 | db 0FFFFh && 5555h 127 | endif 128 | 129 | db 0 | 0AAAAh 130 | dw 0 | 0AAAAh 131 | db 0 || 0AAAAh 132 | dw 0 || 0AAAAh 133 | 134 | db 0AAAAh ^ 0AAAAh 135 | dw 0AAAAh ^ 0AAAAh 136 | 137 | db TRUE and TRUE 138 | db TRUE and FALSE 139 | db TRUE or FALSE 140 | db FALSE or FALSE 141 | db FALSE OR FALSE 142 | db FALSE OR TRUE 143 | db (FALSE OR TRUE) 144 | 145 | 146 | var_1 equ 3 147 | var_2 equ 10 148 | 149 | 150 | db (var_2 - var_1) shr 1 151 | db -(var_2 - var_1) 152 | db 0-(var_2 - var_1) 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /test/test_reg.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | inx g 8 | ldax z 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/test_reg1.asm: -------------------------------------------------------------------------------- 1 | ldax h 2 | ldax hl 3 | ldax z 4 | ldax d 5 | ldax de 6 | ldax b 7 | ldax d 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/test_sign.asm: -------------------------------------------------------------------------------- 1 | 2 | 3 | ;data_neg equ -1 4 | ;data_neg equ (-1) 5 | ;data_neg equ 0-1 6 | ;data_neg equ ((-1)) 7 | ;data_neg equ (((-1))) 8 | data_neg equ ((((-1)))) 9 | 10 | 11 | org 0 12 | 13 | 14 | if 0 15 | 16 | mvi a, -1 17 | mvi b, -2 18 | 19 | lxi b, -1 20 | lxi d, -2 21 | 22 | endif 23 | 24 | 25 | mvi h, data_neg 26 | 27 | 28 | 29 | 30 | 31 | end 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/test_solace.asm: -------------------------------------------------------------------------------- 1 | ;****************************************************************************** 2 | ;Filename: test_solace.asm 3 | ;Description: Program to Test the Solace (SOL-20 emulator). 4 | ;Copyrigth(c): 5 | ;Author(s): Claude Sylvain 6 | ;Created: December 2011 7 | ;Last modified: 29 December 2011 8 | ; 9 | ;Notes: - Solace (SOL-20 emulator) is available at the following 10 | ; place: 11 | ; http://www.sol20.org/solace.html 12 | ;****************************************************************************** 13 | 14 | 15 | ;****************************************************************************** 16 | ; EQU 17 | ;****************************************************************************** 18 | 19 | VDU_MEM_START equ 0CC00h ;VDU Memory Start. 20 | VDU_MEM_END equ 0CFFFh ;VDU Memory End (last location). 21 | 22 | ;BIOS routines addresses. 23 | ;------------------------ 24 | BIOS_KBD_HR equ 0C02Eh ;Keyboard Handler Routine. 25 | 26 | 27 | ;****************************************************************************** 28 | ; MACROS 29 | ;****************************************************************************** 30 | 31 | 32 | ;****************************************************************************** 33 | ;Routine name: GETCH 34 | ;Description: Get key code from the keyboard, if any. 35 | ;Created: 29 December 2011 36 | ;Last modified: 37 | ;Parameters: None. 38 | ; 39 | ;Returns: Z: 40 | ; 0: Key code is available in A. 41 | ; 1: No key code available. 42 | ; 43 | ;Notes: Use BIOS routine. 44 | ;****************************************************************************** 45 | 46 | GETCH macro 47 | call BIOS_KBD_HR ;Call BIOS Keyboard Handler Routine. 48 | endm 49 | 50 | 51 | ;****************************************************************************** 52 | ; TEXT 53 | ;****************************************************************************** 54 | 55 | org 0000h 56 | 57 | 58 | ;****************************************************************************** 59 | ;Description: The entry point. 60 | ;****************************************************************************** 61 | 62 | entry 63 | ;Init. VDU. 64 | ;---------- 65 | mvi a, 30h ;Init. VDU mem. with '0'. 66 | call vdu_mem_init 67 | 68 | if 0 69 | ;Wait for a key using "getchar" routine. 70 | ;--------------------------------------- 71 | entry_00 72 | call getchar ;Wait for a character... 73 | ; cpi 'q' 74 | cpi 'Q' 75 | jnz entry_00 ;Exit on 'q'. 76 | endif 77 | 78 | if 0 79 | ;Wait for a key using "getch" routine. 80 | ;------------------------------------- 81 | entry_00 82 | call getch 83 | jz entry_00 84 | cpi 'q' 85 | jnz entry_00 86 | endif 87 | 88 | if 0 89 | ;Wait for a key using "GETCH" macro. 90 | ;----------------------------------- 91 | entry_00 92 | GETCH 93 | jz entry_00 94 | cpi 'q' 95 | jnz entry_00 96 | endif 97 | 98 | 99 | ;- Increment all VDU memory locations individually, until 100 | ; 'q' key is pressed by the user. 101 | ;********************************************************* 102 | 103 | lxi hl, VDU_MEM_START 104 | 105 | entry_00 106 | ;Update VDU memory location. 107 | ;--------------------------- 108 | mov a, m 109 | inr a 110 | mov m, a 111 | 112 | inx hl ;Next VDU memory location. 113 | 114 | ;Check for HL pointing end of VDU memory. 115 | ;If so, make a roll over on HL. 116 | ;---------------------------------------- 117 | mov a, h 118 | cpi high (VDU_MEM_END + 1) 119 | jnz entry_01 120 | mov a, l 121 | cpi low (VDU_MEM_END + 1) 122 | jnz entry_01 123 | lxi hl, VDU_MEM_START ;Roll over! 124 | 125 | entry_01 126 | call delay256 ;Delay! 127 | 128 | GETCH 129 | jz entry_00 130 | cpi 'q' 131 | jnz entry_00 132 | 133 | ;Clean up VDU memory. 134 | ;-------------------- 135 | mvi a, 20h ;Init. VDU mem. with space. 136 | call vdu_mem_init 137 | 138 | ret ;Return control to system. 139 | 140 | 141 | ;****************************************************************************** 142 | ;Routine name: delay256 143 | ;Description: Do a delay looping 256 times. 144 | ;Created: 29 December 2011 145 | ;Last modified: 146 | ;Parameters: None. 147 | ;Returns: None. 148 | ;Notes: 149 | ;****************************************************************************** 150 | 151 | delay256 152 | ; mvi a, 0 153 | xra a 154 | delay256_00 155 | dcr a 156 | jnz delay256_00 157 | ret 158 | 159 | 160 | if 0 161 | ;****************************************************************************** 162 | ;Routine name: getch 163 | ;Description: Get key code from the keyboard, if any. 164 | ;Created: 29 December 2011 165 | ;Last modified: 166 | ;Parameters: None. 167 | ; 168 | ;Returns: Z: 169 | ; 0: Key code is available in A. 170 | ; 1: No key code available. 171 | ; 172 | ;Notes: Use BIOS routine. 173 | ;****************************************************************************** 174 | 175 | getch 176 | call BIOS_KBD_HR ;Call BIOS Keyboard Handler Routine. 177 | ret 178 | endif 179 | 180 | 181 | ;****************************************************************************** 182 | ;Routine name: getchar 183 | ; 184 | ;Description: - Wait until a key is pressed on the keyboard. Then 185 | ; return the key code. 186 | ; 187 | ;Created: 29 December 2011 188 | ;Last modified: 189 | ;Parameters: None. 190 | ; 191 | ;Returns: A: 192 | ; Key code. 193 | ; 194 | ;Notes: Use BIOS routine. 195 | ;****************************************************************************** 196 | 197 | getchar 198 | call BIOS_KBD_HR ;Call BIOS Keyboard Handler Routine. 199 | jz getchar 200 | ret 201 | 202 | 203 | if 0 204 | ;****************************************************************************** 205 | ;Routine name: kbhit 206 | ;Description: Tell if a key was pressed. 207 | ;Created: 29 December 2011 208 | ;Last modified: 209 | ;Parameters: None. 210 | ; 211 | ;Returns: Z: 212 | ; 0: A key was pressed. 213 | ; 1: No key pressed. 214 | ; 215 | ;Notes: Use BIOS routine. 216 | ;****************************************************************************** 217 | 218 | kbhit 219 | call BIOS_KBD_HR ;Call BIOS Keyboard Handler Routine. 220 | ret 221 | endif 222 | 223 | 224 | ;****************************************************************************** 225 | ;Routine name: vdu_mem_init 226 | ;Description: Initialize SOL-20 VDU memory. 227 | ;Created: 17 December 2011 228 | ;Last modified: 28 December 2011 229 | ; 230 | ;Parameters: A: 231 | ; Code to use to initialize VDU memory. 232 | ; 233 | ;Returns: void 234 | ;****************************************************************************** 235 | 236 | vdu_mem_init: 237 | push b 238 | push h 239 | 240 | mov b, a ;Save parameter. 241 | 242 | lxi h, VDU_MEM_START 243 | 244 | vdu_mem_init_00: 245 | ; mvi m, 41h ;Code to use to fill VDU Memory. 246 | mov m, b ;Code to use to fill VDU Memory. 247 | inx h ;Next VDU memory location. 248 | 249 | ;Loop until (VDU memory + 1) is reached. 250 | ;--------------------------------------- 251 | mov a,h 252 | ; cpi (VDU_MEM_END + 1) >> 8 253 | cpi high (VDU_MEM_END + 1) 254 | jnz vdu_mem_init_00 255 | mov a,l 256 | ; cpi (VDU_MEM_END + 1) & 00FFh ;No more supported by asm8080 V1.01 257 | ; cpi (VDU_MEM_END + 1) and 00FFh 258 | cpi low (VDU_MEM_END + 1) 259 | jnz vdu_mem_init_00 260 | 261 | pop h 262 | pop b 263 | 264 | ret 265 | 266 | 267 | ;****************************************************************************** 268 | ;****************************************************************************** 269 | 270 | end 271 | 272 | 273 | 274 | 275 | -------------------------------------------------------------------------------- /windows/Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | cl -D_TGT_OS_WIN64=1 -Feasm8080.exe ../src/*.c strncasecmp.c 5 | 6 | clean: 7 | del *.obj *.exe 8 | -------------------------------------------------------------------------------- /windows/strncasecmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int strncasecmp (const char* s1, const char* s2, size_t n) 5 | { 6 | if (n == 0) 7 | return 0; 8 | 9 | while (n-- != 0 && tolower(*s1) == tolower(*s2)) 10 | { 11 | if (n == 0 || *s1 == '\0' || *s2 == '\0') 12 | break; 13 | s1++; 14 | s2++; 15 | } 16 | 17 | return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2); 18 | } 19 | --------------------------------------------------------------------------------