; Byte Wide Rom Simulator Loader (lp.com) ;======================================== ; Last revision 9_Nov_82 ; ; This program is designed to load files from a CPM system ; into the ROMSIM-1A rom simulator made by Inner Access Coperation. ; To use this program type its name (lp) followed by the file you ; wish to load. For example, assume that the file you want in the ; simulator rom is call DJ19.COM. Then the input line would look like: ; ; A>lp dj19.com ; ; The first thing this program does is to open the file. If the ; file doesn't exist it prints 'File non-existant' and then returns to ; the operating system. If the file does exist then it is read into the ; default DMA area a record at a time and transferred into the rom ; starting at rom address 0. ; The rom simulator uses four i/o ports. The first two are used ; to specify an address in the rom simulator. The next i/o port is used ; to either read or write data to/from the simulator. The last i/o port ; is used to enable external accesses to the rom simulator. Any access ; to i/o ports X0-X2 causes shuts off external accesses to the simualtor. ; Any read or write to port X3 causes external accesses to be allowed. ; The base address of the i/o ports is switch selectable. It ; is currently set to port 'E0'. The i/o port usage in summary is: ; ; E0 - lo-byte address ; E1 - hi-byte address ; E2 - data in/out ; E3 - enable external accesses ; ; To set the base address of the i/o port uses switches 1 - 4. ; Switch 1 is the left-most switch as you're looking at the front of ; the board. Switch 1 is also the least signifigant bit. So to set the ; i/o port to base address 'E0' you would set switches 1-3 to 'off' ; (depress the top side of the switches) and switch 4 to on (depressed ; on the lower side). ; Switches 5, 6 and 7 set the type of rom being simulated. For ; a 2732. switches 5 and 7 should be 'on' (lower side depressed) and ; switch 6 should be 'off' (top side depressed). ; This program does not check to see if the program being ; loaded will fit into the rom. ; Note that, although this rom simulator is capable of ; simulating both word and byte wide roms, only byte wide roms are ; loaded in this version of the loader. To load word wide roms you ; have to load evey other byte with an 8K offset. ; page ;--------------------------- ; General Definition Section ;--------------------------- .z80 aseg org 100h ; BDOS addresses bdos equ 05h ; Entry point to BDOS retcpm equ 0 ; Return point to CPM (BDOS) dflfcb equ 5ch ; Starting address of the default FCB dfldma equ 80h ; Default DMA address ; BDOS command codes prnstr equ 9 ; Print a string opnfil equ 0fh ; Open a file rdseq equ 14h ; Read a file Sequentially ; BDOS return codes badopn equ 0ffh ; Could not successfully open the file readok equ 0 ; Read was successful page ;--------------------------- ; Main Line Simulator loader ;--------------------------- ; ; This is the main line of the loader program. First the file ; is opened. If the open operation fails then you'll get kicked out to ; the operating system. If the open is successful then the file will ; be read and transferred to the rom. After the entire file has been ; transferred a write is made to i/o port X3 (X, the i/o port base ; address, is currently equal to E). This enables external accesses to ; the rom simulator memory. The program then returns you to the ; operating system. ; This main line has one subroutine called 'movbuf' which ; moves the data starting at the default DMA address into the rom ; simulator memory. ld c,opnfil ; Open the file ld de,dflfcb call bdos cp badopn ; if (file eq non-existant) jp nz,ldlp ld c,prnstr ld de,noopn call bdos ; Print 'File is non-existant' jp retcpm ; return to CPM ldlp: ld c,rdseq ; Transfer the file to the simulator ld de,dflfcb ; Repeat call bdos ; read the next record cp readok ; if (end-of-file eq true) jp nz,ldbrk ; break ldskp1: call movbuf ; move the data into the rom simulator jp ldlp ldbrk: out (0e3h),a ; Enable external access to rom simulator jp retcpm ; Return to CPM page ;----------------------------------------------- ; Move the current buffer into the rom simulator ;----------------------------------------------- ; ; This subroutine moves the current contents of the buffer ; area (starting at the default DMA address )into the rom simulator. ; The buffer area (dflbuf) is 128 bytes long. ; See the description at the start of this program for an ; explanation of the i/o port assignments and functions. Note that ; only the first three i/o ports are manipulated by this subroutine. movbuf: ld hl,dfldma ;hl:= dma address ld de,(cprom) ;de:= target address ld bc,0128 ;bc:= byte count loop1: ld a,e ;Repeat out (0e0h),a ;output the lo_order address ld a,d out (0e1h),a ;output the hi_order address ld a,(hl) out (0e2h),a ;output the data inc hl ;source_pointer:= source_pointer + 1 inc de ;dest_pointer:= dest_pointer + 1 dec bc ;counter:= counter - 1 ld a,b or c jp nz,loop1 ;Until (counter eq 0) ld (cprom),de ; Save the current rom pointer ret ;----------- ; Data Areas ;----------- ; Messages noopn: db "File is non-existant$" ; Data cprom: dw 0 ; Current rom simulator address end