page , 132 title PL/M Application Tiny Startup Code subttl Copyright (c) 2011-2012,2018-2020,2024, the ACME Software Deli ; ============================================================================ ; This program is distributed in the hope that it will be useful, but ; WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE ; ; Permission to use for any purpose, modify, copy, and make enhancements ; and derivative works of the software is granted if attribution is given to ; R.M. Gillmore, dba the ACME Software Deli, as the author ; ; While the ACME Software Deli does not work for money, there is nonetheless a ; a significant amount of work involved. The ACME Software Deli maintains the ; rights to all code written, though it may be used and distributed as long as ; the following conditions are maintained. ; ; 1. The copyright statement at the top of each code block is maintained in ; your distribution. ; 2. You do not identify yourself as the ACME Software Deli ; 3. Any changes made to the software are sent to the ACME Software Deli ; ============================================================================ page name tinyStart .186 ; ****************************************************************************** ; ****************************************************************************** ; ** ; ** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ; ** ; ** This module does not call the PL/M Start module, so there is no parsing ; ** of the command line ... It calls main() directly ; ** ; ** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ; ** ; ****************************************************************************** ; ****************************************************************************** ; _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*-_ ; the segments are in this order for good reason. if the order is changed, ; there is a real good chance that it will break lots of applications ; ; the segment/group order MUST be: ; 'Const' ; 'Code' ; 'Data' ; 'Stack' ; 'Memory' ; _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*-_ plmLibrary_Code segment public 'Code' plmLibrary_Code ends plmLibrary_Const segment public 'Const' plmLibrary_Const ends ; _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*-_ ; ; This segment MUST be listed before asmStart_data segment so that the linker will ; put it lower in memory, allowing the initializeDataArea procedure to work without ; losing the pspOffset and pspSelector data ; ; _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*-_ protectedData segment public 'Data' protectedData ends plmLibrary_Data segment public 'Data' plmLibrary_Data ends stack segment public 'Stack' ; org 0ffeh ;stackEnd label word stack ends memory segment public 'Memory' ; org 0 ;memoryVariable label word memory ends plmLibrary_Code segment public 'Code' plmLibrary_CGroup group plmLibrary_Code plmLibrary_DGroup group plmLibrary_Data assume Cs:plmLibrary_CGroup DOS equ 21h FATAL_ERROR equ 2 db '@(#)DOS Library Copyright (c) 2011-2012,2018-2024, the ACME Software Deli', 0 ifndef SMALL db '@(#)tinyStrt.a86 $Author: rmgillmore $ $Date:: 2025-05-04 19:35:39#$:', 0 endif ; -------------------------------------------------------------------------------- ; Function: Start ; ; This is first code executed when the Operating System (DOS) turns control over ; to the application. These are the high-level steps taken for every application ; ; * Capture the current context, storing for possible use at a later time ; * Release memory that the application is not using ; * Initialize the memory segments in the Data category ; * Turn control to the command line and environment parsers who will ; then turn control to the core of the application's functionality ; -------------------------------------------------------------------------------- extrn main:far extrn exit:far public tinyStart tinyStart proc far ; determine how much conventional memory the application really needs, ; and free the remainder (this should allow the DOS memory allocation ; to work as defined) ; adjust the stack to 64k bytes, then set the stack ptr to the top of ; that stack ( that will mean that we will need to adjust the and of ; available memory manually ) mov Sp, 0 ; we want a maximum stack segment mov Bx, Ss add Bx, 1000h ; adjusted location of the Memory segment mov Ss, Bx mov Ax, plmLibrary_DGroup ; restore the data segment mov Ds, Ax call main add sp, 4 ; two registers were pushed for the call leaveApplication: push ax call exit tinyStart endp plmLibrary_Code ends end tinyStart