;Revised (along with companion LOADRSX and RSX modules) to ;install below alien RSXs, including Plu*Perfect's non ;page-aligned stuff. Many thanks to Plu's Bridger Mitchell ;for his diagnostic skills. Bruce Morgen - June 13, 1987 ;UPDATED to LBRDSK23 version - Bruce Morgen June 10, 1987 ;This source is copyright 1984 by Jim Lopushinsky to discourage ;commercial use. ; ;This is the loader program for loading the RSX manager for use ;with LBRDISK and other relocatable software that conforms to the ;RSX format as documented by Digital Research for CP/M Plus ; ;March 5/84 ;This code is written using Zilog mnuemonics, altho no Z80 specific ;instructions are used. I learned Zilog before Intel, and I find ;them easier to use and less confusing. ; ;To compile and link, do the following: ;M80 (Z80ASM, ZAS etc.), L80 (SLRNK, ZLINK, PROLINK, ;PDLN, etc.) LINK, ZSID (DDT, DDTZ, etc.) needed. ; ;M80 =SETRSX <=== To compile this source ;L80 SETRSX,LOADRSX,SETRSX/N/E <=== Produces SETRSX.COM ;M80 =RSX <=== To compile the RSX manager ;LINK RSX[OP] <=== To produce RSX.PRL ;ZSID SETRSX.COM <=== Invoke ZSID and load SETRSX.COM ;IRSX.PRL <=== Bring in RSX.PRL ;R200 <=== at the proper offset ;G0 <=== Back to CP/M ;SAVE 5 SETRSX.COM <=== SETRSX is now ready to use. .z80 public $memry extrn loadrs bdos equ 5 start: ld sp,stack ;Need some stack ld c,12 call bdos ;Return CP/M version and 0f0h ;Any version of cpm 2.x is ok. cp 20h jp z,verok ;Version is 2.x badver: call ilprt db 'This version of SETRSX requires CP/M 2.x',0 rst 0 verok: ld a,h ;don't allow MP/M. or a jp nz,badver ;jump if it's not CP/M ld hl,(bdos+1) ld (bdose),hl call chkrsx ;Determine if RSX manager already loaded ld hl,($memry) ;Get base of free ram ld a,l ; or a ;is it at a page boundary? jp z,adok inc h ;make it a page boundary ld l,0 adok: ;HL now points to the PRL file to be relocated LD A,(BDOS+2) LD B,A LD A,(2) SUB B CP 0EH ld a,8 ;A = non-zero = load below the CCP JP Z,JBCCP XOR A JBCCP: call loadrs ;relocate the RSX, and adjust pointers jp z,loadok ;Jump if load sucessful dec a ;A = 1 ? jp nz,noroom call ilprt ;return code = 1: HL not on page boundary db 'Not on page boundary',0 rst 0 noroom: call ilprt ;rerurn code = 2: out of memory db 'Insufficient memory',0 rst 0 loadok: ;here if load is sucessful ld hl,(bdos+1) ;get load address of RSX manager ld l,1bh ;point to pointer to WBOOT routine ld e,(hl) ;get address of WBOOT routine in [DE] inc hl ld d,(hl) inc hl push hl ;save for later ld hl,(1) ;get address of BIOS WBOOT routine inc hl ;go past jump inst. ld c,(hl) ;get BIOS WBOOT address in [BC] inc hl ld b,(hl) ld (hl),d ;Patch in RSX WBOOT address into BIOS dec hl ld (hl),e pop hl ;restore.. points to BIOS WBOOT save ld (hl),c ;Save old BIOS WBOOT address inc hl ld (hl),b inc hl ex de,hl ld hl,(bdose) ex de,hl ld (hl),e inc hl ld (hl),d rst 0 ;Back to CP/M-- RSX manager now active ;......... ; ; ;CHKRSX -- Determine if RSX manager is already active. If it is, ;remove it, and return to CP/M. ; ; chkrsx: ld hl,(bdos+1) ;get top of TPA address LD A,6 SUB L RET NZ chklop: ld l,18h ;point to loader flag inc (hl) dec (hl) jp nz,tstrsx ;We may be at RSX manager (or BDOS) ld l,0bh ;normal RSX--point to next RSX page ld h,(hl) ;get next RSX address jp chklop ;and loop for more. tstrsx: ;here if we reached the RSX manager or the BDOS ld l,10h ;point to RSX name ld de,rsx call comp8 ;See if in fact it is the RSX manager ret nz ;return if we reached the BDOS call ilprt db 'RSX removed',0 xor a ld (4),a ;so that the CCP doesn't choke ld c,59 ;Bdos function 59 = call RSX manager ld de,-1 ;DE = FFFFH = remove the RSX manager jp bdos ;RSX manager removes itself, and all ;RSXs below it, then Warm boots. ;.......... ; ; ;ILPRT In-line print routine ; ilprt: pop hl ld a,(hl) inc hl push hl or a ret z ld e,a ld c,2 call bdos jp ilprt ;........... ; ; ;COMP8 Compare 8 byte strings at [DE] and [HL] ; ; comp8: ld c,8 comp: ld a,(de) cp (hl) ret nz inc hl inc de dec c jp nz,comp ret $memry: ds 2 ;L80 patches in top of free ram here. rsx: db 'RSX ' ;Name of the rsx manager ; ^^^^^^^^ must be 8 bytes bdose: dw 0 ds 40 ;lots of room for stack stack equ $ end start ;so that L80 knows this is a main program