





                                  ASM STARTUP CODE

                        Assembly Language Startup Source Code

                                    Version 1.00

                                     READ1ST.TXT

                           Copyright (c) 1997 Raymond Moon
                                 ALL RIGHTS RESERVED


          LIMITED WARRANTY  STRTUP10 is sold AS IS.

          MoonWare makes no representations or warranties, expressed or
          implied, about the contents hereof, including, without
          limitations, any implied warranties of merchantability or fitness
          for a particular purpose, all of which MoonWare Shareware
          expressly disclaims.  Neither MoonWare Shareware, nor anyone
          involved in the distribution of this software shall be liable for
          any direct, indirect, consequential, or incidental damages
          arising out of the use, the results of use, or inability to use
          such product even if I have been advised of the possibility of
          such damages or claim.

          SOFTWARE COPYRIGHT NOTICE

          Copyright (c) 1997 by Raymond Moon
          ALL RIGHTS RESERVED

          The ASM Startup assembly code is copyright (c) 1997 by Raymond
          Moon.  Non-registered users may use this software for a 30 day
          trial period.  At the end of that 30 day trial period, you must
          become a registered user or stop using the ASM Startup assembly
          code.

          SHAREWARE DISTRIBUTION

          ShareWare is not FreeWare.  I have chosen this method of
          distributing the ASM Startup assembly code so you, the user, can
          use it for a trial period to see if it meets your needs.  If it
          does, you must become a registered user.  Registered users will
          receive the latest version if they registered an older version,
          or they will receive a free upgrade to the next version.
          Registered and non registered users are authorized to upload the
          zip file, STRTUP10.ZIP, to any Bulletin Board System as long as
          the zip file has not been modified

          FILE LOCATIONS

          The Startup files are located in the following directories if the
          \d switch is used to unzip STARTUP.ZIP, the .zip file within
          STRTUP10.ZIP.



                                          1





          READ1ST.TXT                                ALIBM.LIB
              \BATS                                  ALIBL.LIB
                  MAKELIBS.BAT                       ALIBH.LIB
                  RMLIBS.BAT                     \LIBSRC
                  SU.BAT                             BIN2HEX.ASM
                  SUS.BAT                            PRINT.ASM
              \DEMO                                  PUTS.ASM
                  DEMO0.ASM                          STACK.ASM
                  DEMO12.ASM                         STCKCHK.ASM
                  DEMO3.ASM                          UTOA.ASM
              \DOC                               \STARTUP
                  STARTUP.PDF                        STARTUP0.ASM
              \INCLUDES                              STARTUP1.ASM
                  LIB.INC                            STARTUP2.ASM
                  PROCESOR.INC                       STARTUP3.ASM
                  STARTUP.INC                        SUDATA.ASM
              \LIBS                                  SUDATA3.ASM
                  ALIBT.LIB                      \TMPLATES
                  ALIBS.LIB                          ASMPROC.ASM
                  ALIBC.LIB                          MAIN.ASM

          DOCUMENTATION

          As the documentation is extensive and requires some graphics to
          illustrate properly memory and stack usage, I have used Adobes
          .pdf format.  You will need Adobe Acrobat Reader Version 3.0.
          You can download this reader if you do not have it from Adobe:

              http://www.adobe.com/productinfo/index.html

          To understand how to use this startup code and take full
          advantage of this code, you will need to read the documentation.

          WHAT IS STRTP10

          Back in 1986, I started to write stand alone 100% assembly
          language programs.  Having been programming in C, I wanted to
          start assembly language programs as I started C programs, that is
          with the MAIN procedure.  Unfortunately, assemblers do not come
          out of package with startup code, so I set out to develop that
          code.  The goal was to have startup code that provided a uniform
          environment in which to start assembly language programs.  This
          uniform environment would include: (1) the command argument(s) in
          the form of argc and *argv[]; (2) the environmental strings in
          the form of *envp[]; (3) global variables that are initialized to
          system and program global information; and (4) unneeded memory
          released.  All memory models, all processors and executable
          formats would be supported.  Lastly, the code would reside in
          .lib files so all the work would be done by the linker.

          SUMMARY OF FEATURES

          The assembly language startup code performs the following
          functions:


                                          2





              Initializes the following global variables:
                  DGRP, segment address of DGROUP;
                  STACK_BOTTOM, offset to stack bottom in DGROUP;
                  PSP, segment address of the PSP;
                  NEXTPARA, segment address of the next available memory
                  paragraph;
                  ENVIRON, segment address of the programs ENVIRONMENT;
                  OSMAJOR, the integer part of the OS system;
                  OSMINOR, the decimal part of the OS system; and
                  ENV_STR_LEN, length of environmental strings.
              Initializes DS and ES segment registers to DGROUP;
              Shrinks memory down to the size of the program by releasing
              all memory above the program;
              Supports returning an exit code to the operating system;
              Provides the count of command line arguments in the form of
              argc;
              Provides the executables drive, full path, filename and
              extension as *argv[0];
              Provides pointers as *argv[] to the command line arguments
              parsed in ASCIIZ format;
              Provides pointers as *envp[] to the environmental variables
              parsed in ASCIIZ format;
              Supports both .exe and .com executable formats; and
              Supports all memory models from tiny to huge.

          Since not all of these features are needed in every program I
          write, four versions of the startup code were written.  They are:
              Version 0, STARTUP0.ASM, supports all above except argc,
              *argv[] and *envp[] features;
              Version 1, STARTUP1.ASM, supports all of Version 0 plus argc
                  and *argv[] features.  *argv[0] is the first command
                  line argument vice the program name;
              Version 2, STARTUP2.ASM, supports all of Version 1, and
              *argv[0] is the program name; and
              Version 3, STARTUP3.ASM, supports all the above features.

          There are two support files that contain all the global data
          initialized by the startup code.  These files are:
              SUDATA.ASM declares all global variables common to all
              startup procedures.  These global variables are:
                  DGRP, segment address of DGROUP;
                  STACK_BOTTOM, offset to stack bottom in DGROUP;
                  PSP, segment address of the PSP;
                  NEXTPARA, segment address of the next available memory
                  paragraph;
                  ENVIRON, segment address of the programs ENVIRONMENT;
                  OSMAJOR, the integer part of the OS system; and
                  OSMINOR, the decimal part of the OS system.
              SUDATA3.ASM declares the global variable unique to
              STARTUP3.ASM that is:
                  ENV_STR_LEN, length of environmental strings.

          Included are templates and include files to facilitate the use of
          the startup code:


                                          3





              MAIN.ASM, an assembly language template for the MAIN
                  procedure of a program using any version of the startup
                  code;
              ASMPROC.ASM, an assembly language template for non MAIN
                  procedures;
              LIB.INC, an include file that defines the correct ALIB?
                  LIB.INC, an include file that ensures that the correct
                  library file is specified in the .obj file and provides
                  references to all procedures in the libraries.
              PROCESOR.INC, an include file that specifies the target
                  processor for which the source codes will be assembled;
                  and
              STARTUP.INC, an include file specifies references to all
                  global variables specified by the startup code.

          So that you can see how to write 100% assembly language programs,
          I have included the following source code files.  These source
          code files were used to write demonstration programs that
          illustrate all the features of the startup code.  The last four
          procedures are general purpose procedures that can be used in any
          program.  These files are:
              DEMO0.ASM, MAIN procedure that demonstrates all the features
                  of version 0 of the startup code;
              DEMO12.ASM, MAIN procedure that demonstrates all the
                  features of versions 1 and 2 of the startup code;
              DEMO3.ASM, MAIN procedure that demonstrates all the features
                  of version 3 of the startup code;
              HEX2BIN.ASM, a procedure that converts a binary word to an
                  ASCIIZ hexadecimal string;
              PRINT.ASM, a procedure that displays the passed string on
                  the console;
              PUTS.ASM, a procedure that displays the passed string on the
                  console and then sends a carriage return and line feed
                  so the cursor will be at the start of the next line; and
              UTOA.ASM, a procedure that converts an unsigned word to an
                  ASCIIZ decimal string.

          Lastly, to make the use of this code even easier, I have included
          .lib files with the above procedures included except as noted.
          The library files are:
              ALIBT.LIB, a library file of all the above source files,
                  except MAIN and startup procedures, assembled in the
                  tiny memory model;
              ALIBS.LIB, a library file of all the above source files,
                  except MAIN procedures, assembled in the small memory
                  model;
              ALIBC.LIB, a library file of all the above source files,
                  except MAIN procedures, assembled in the compact memory
                  model;
              ALIBM.LIB, a library file of all the above source files,
                  except MAIN procedures, assembled in the medium memory
                  model;




                                          4





              ALIBL.LIB, a library file of all the above source files,
                  except MAIN procedures, assembled in the large memory
                  model;
              ALIBH.LIB, a library file of all the above source files,
                  except MAIN procedures, assembled in the huge memory
                  model; and

          ASSEMBLER REQUIREMENTS

          The current version of the startup code was developed on
          Microsoft MASM version 6.11d. Suitability of the code for any
          earlier version of MASM or other assemblers has not been
          verified.

          TARGET PROGRAM REQUIREMENTS

          The programs produced using this version of ASM Startup Code are
          required to execute on versions of DOS 3.0 or later.

          USER RESPONSIBILITIES

          As mentioned earlier, ShareWare is not FreeWare.  You, as the
          user, have a 30 day trial period to evaluate the ASM STARTUP code
          and associated supporting files.  You are not authorized to
          distribute programs based upon any code included in STRTUP10.ZIP
          during this trial period.  If the code meets your needs and you
          want to continue to use the code to write programs, you must
          register your copy of the ASM STARTUP code.  When you register,
          there are several options that are explained below.

          Personal Registration - The basic Non-Commercial Registration is
              $10.00 that allows you to use ASM Startup Source Code on one
              computer at a time for personal use.  With a personal
              license, you may not distribute any of programs, whether
              commercial, ShareWare or FreeWare, based any code from ASM
              STARTUP.

          Commercial Registration - The basic Commercial Registration is
              $20.00 that allows use ASM STARTUP Code on up to ten stand
              alone or networked computers for commercial use.
              Registration for each additional computer is $1.00 each.
              With a commercial license, you can distribute any programs
              using ASM Startup Source Code as long as my copyright appears
              in the documentation, and the source code itself is not
              distributed without prior agreement of the author.

          Enterprise RegistrationContact the author.

          Any user, registered or non-registered, may upload the original
          and unmodified STRTUP10.ZIP file to any Bulletin Board System.  I
          use the authentication feature of PKWARES ZIP program.  If
          unzipping STRTUP10.ZIP with PKWAREs UNZIP software does reveal
          the -AV after each filename, the file has not been modified.
          STRTUP10.ZIP may be distributed on diskettes or CDROM if no more


                                          5





          than $5.00 per disk or $25.00 for CDROM to cover the cost of the
          media and any shipping costs.

          AUTHENTICITY OF STARTUP CODE

          To ensure yourself the you have an authentic version, check that
          all files -AV after each file when you unzip STRTUP10.ZIP.  If
          your version does not unzip with an -AV after each file, please
          contact the me with the location where you got the file.  I can
          be contacted at the addresses below.

          USER COMMENTS

          User comments are appreciated at any time.  If your comments
          result in a product improvement, you will receive a free upgrade.
          Please send any comments to:
              E-mail
                  raymoon@moonware.dgsys.com
              Mail
                  Raymond Moon
                  16005 Pointer Ridge Drive
                  Bowie, MD  20716-1744


































                                          6







                              STARTUP Registration Form


          Name:   _________________________________________________________


          Company:    _____________________________________________________


          Address:    _____________________________________________________


                      _____________________________________________________


          City, State & Zip:  _____________________________________________


          e-mail Address: _________________________________________________


          Registration

                  Basic Non-Commercial ($10.00)            $_______________

                  Basic Commercial ($20.00)                $_______________

          ______  Additional Commercial Computers
                  ($1.00 each)                             $_______________

                                                   TOTAL:  $_______________

          Comments:





















                                          7
