page , 132 title PL/M Application Startup Code subttl Copyright (c) 2011-2012,2018-2020, 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 startSup .186 protectedData segment public 'Data' programSegmentSelector Dw ? programSegmentOffset Dw ? protectedData ends plmLibrary_Code segment public 'Code' ifndef SMALL db '@(#)startSup.a86 $Author: rmgillmore $ $Date:: 2025-05-04 19:35:39#$:', 0 endif plmLibrary_Code ends stack segment public 'Stack' stack ends memory segment public 'Memory' ; memoryVar dw ? memory ends plmLibrary_Data segment public 'Data' decimalString db 15 dup (?) plmLibrary_Data ends plmLibrary_CGroup group plmLibrary_Code plmLibrary_DGroup group plmLibrary_Data plmLibrary_Code segment public 'Code' plmLibrary_CGroup group plmLibrary_Code assume Cs:plmLibrary_CGroup ; -------------------------------------------------------------------------------- ; Function: storePSP / getPSP ; ; store / retrieve the address of the initial program segment prefix (really ; more of a program header). ; -------------------------------------------------------------------------------- public storePSP storePSP proc far ; we MUST be careful not to modify ES register since that is the selector ; in the PSP address push Ds mov Ax, seg programSegmentSelector mov Ds, Ax assume Ds:protectedData mov Ax, Es mov programSegmentSelector, Ax xor Ax, Ax mov programSegmentOffset, Ax pop Ds ret storePSP endp public getPSP getPSP proc far push Ds mov Ax, seg programSegmentSelector mov Ds, Ax assume Ds:protectedData mov Dx, programSegmentSelector mov Ax, programSegmentOffset pop Ds ret getPSP endp ; -------------------------------------------------------------------------------- ; Function: initializeDataArea ; ; Initialize the data area with zeroes (making it a lot like the starting ; environment for a C application) ; -------------------------------------------------------------------------------- WORDS_PER_PARA equ 8 ; a paragraph is this many words public initializeDataArea ; _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*-_ ; ; if the segment/group order is different than noted at the top of this module, ; this may not work, and perhaps even cause undesirable events (like a crash) ; ; _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*- _-*-_ initDataArea_Params struc init_oldFrame Dw ? rtnAddress Dd ? startingSegment Dw ? initDataArea_Params ends initializeDataArea proc far push Bp mov Bp, Sp ; the starting segment for the clearing is placed in DX by the caller mov Dx, [Bp].startingSegment mov Bx, stack ; the starting segment for "do not touch" xor Ax, Ax ; we want to store zero in every word clearSegment: cmp Dx, Bx ; are we at the end? jge doneClearing ; if so, break out of the loop mov Es, Dx ; the destination address is ES:DI xor Di, Di mov Cx, WORDS_PER_PARA rep stosw inc Dx ; next paragraph, please jmp clearSegment doneClearing: pop Bp ret initializeDataArea endp plmLibrary_Code ends end