home *** CD-ROM | disk | FTP | other *** search
- e
- _*********************************************************
- _* *
- _* module name : LOAD.ASM *
- _* *
- _* Maintenance log *
- _* --------------- *
- _* *
- _* date time action *
- _* ---- ---- ------ *
- _* 25/02/89 02:00 initial coding *
- _* 29/03/89 19:20 tidy up and fix *
- _* 03/04/89 22:00 further tidy up *
- _* 03/04/89 23:00 change brackets, fix ass bugs *
- _* 05/04/89 19:00 fixed the patchend bug *
- _* 06/04/89 23:30 move zero defns and fix init bug *
- _* 25/04/89 22:30 fix bugs, added $ff05-$ffff copy *
- _* 29/04/89 9:55 updated patch table + other mods *
- _* 05/05/89 17:50 fixed the page area bugs *
- _* 22/05/89 18:05 updated for new options on locstor *
- _* 18/06/89 19:00 System registers placed on stack *
- _* 25/06/89 18:10 Save the stack pointer missing *
- _* 04/07/89 18:50 page 0 and 1 can be in any ram *
- _*********************************************************
-
-
- _*********************************************************
- _* *
- _* routine : INITLOAD - initialise the loader *
- _* by copying it then patching it *
- _* *
- _* entry *
- _* ----- *
- _* none *
- _*.......................................................*
- _* used *
- _* ---- *
- _* A,X,Y *
- _*.......................................................*
- _* exit *
- _* ---- *
- _* none *
- _*********************************************************
-
-
-
-
- _ equates used
-
- copystrt = $e000
- ram0conf = $3f
- filenum = 1
- device = 8
- secondad = 1
- defpri = 128
- loadprg = $f265
- errload = $f5b5
-
-
- _ other required storage
-
- pritext res 3
- savecnt res 1
- stktemp res 1 _ area to save stack pointer
-
- _
- _ Start of the code
- _
-
- initload equ *
- ¥ #zeroadd
- » ldaset _ for LDAFAR
- » staset _ for STAFAR
- ¥ #>copystrt
- » zeroadd
- ¥ #<copystrt
- » zeroadd+1
- ƒ #0
-
- _
- _ copy the code from $e000 to $feff
- _ Note that as this could run in BANK 15, ie with system ROMs
- _ enabled, you can LDA from kernal ROM and STA into RAM without
- _ having to change configurations. When you try to write to ROM
- _ it actually writes to the RAM underneath.
- _
-
-
- initlod1 equ *
- ₧ #$00
- £ ldafar
- ₧ #ram0conf
- £ stafar
- ÿ zeroadd
- ê initlod1
- ÿ zeroadd+1
- ¥ zeroadd+1
- æ #$ff
- ê initlod1
-
- _
- _ copy the code from $ff05 - $ffff
- _
- ƒ #5
- initlod9 equ *
- ₧ #0
- £ ldafar
- ₧ #ram0conf
- £ stafar
- Ü
- ê initlod9
-
-
- _ code copied, now patch it.
-
- ₧ #0
- ƒ #0
- patchlop equ *
- ¥ patchtab,x
- » zeroadd
- ¥ patchtab+1,x
- » zeroadd+1
- ¥ patchtab+2,x
- ░ savecnt
- ₧ #ram0conf
- £ stafar
- ₧ savecnt
- Ö
- Ö
- Ö
- Æ #patchend
- â patchlop
-
- _ code now patched so return to caller
-
- ¬
-
- patchtab equ *
- db $73,$e5,$ea _ remove SEI
- db $ee,$f3,$ea _ remove SEI
- db $ba,$e5,$ea _ remove CLI
- db $8f,$f4,$ea _ remove CLI
- db $54,$f4,$2c _ remove test for run/stop
- db $57,$f4,$4c _ jmp over check for run/stop flag
- db $58,$f4,$5c
- db $59,$f4,$f4
- db $d5,$f2,$4c _ jmp over check for run/stop flag
- db $d6,$f2,$da
- db $d7,$f2,$f2
- db $21,$f4,$4c _ point to new code
- db $22,$f4
- db >burstmod
- db $23,$f4
- db <burstmod
- db $b0,$f2,$4c _ point to new code
- db $b1,$f2
- db >loadmod
- db $b2,$f2
- db <loadmod
- db $51,$f4,$f8 _ file read to 248
-
- patchend equ * - patchtab
-
-
- _*********************************************************
- _* *
- _* routine : LOAD - the load routine. *
- _* cmd format : L progname,pri *
- _* *
- _* entry *
- _* ----- *
- _* CHARBUFF - command line input *
- _* Y - position in the command buffer *
- _*.......................................................*
- _* used *
- _* ---- *
- _* A,X,Y *
- _*.......................................................*
- _* exit *
- _* ---- *
- _* none *
- _*********************************************************
-
-
- load equ *
- ¥ #prgnorun
- db $2c
- execute equ *
- ¥ #prgrun
- » option
- £ readload _ read information into prgname and get pri
- â nosyntax
- ¬
-
-
- _ Ok, we are ready to load, We now call the patched code for the loader. First
- _ by switching the bank to RAM, then calling the routine. This method
- _ saves the problem of having to code a full loader with serial routines
- _ which would have to be done for a full operating system.
-
- nosyntax equ *
- £ locfree _ locate a free entry in the table
- â allok
- ¥ #6
- ¢ dispmess
-
- allok equ *
- ¥ #$3e _ RAM block 0, but all I/O available
- » confreg
-
- _ setup for the load routine
-
- ¥ #filenum
- » lfn _ LFN
- ¥ #device _ serial device
- » dev
- ¥ #secondad _ SA
- » sa
- ¥ namelen
- » prgnlen
- ¥ #>prgname
- » prgnadd
- ¥ #<prgname
- » prgnadd+1
- ¥ #0 _ bank number 0, not configuration no.
- » namebank _ bank where name is found.
- ¥ #$00
- » iomode _ stop all output from system
-
- ¥ #11
- £ dispmess
- £ loadprg _ calls code within this subroutine block
- â noloderr
- ¥ #9
- ¢ dispmess
-
- _ program now in memory, so relocate, then setup table entry
- _ note the end address is in X,Y and the load routine has already
- _ set up some parameters for the relocation.
-
- noloderr equ *
- ░ newend
- ▒ newend+1 _ save prog end address
-
- ¥ #12
- £ dispmess
- £ reloc _ newexec passed back ny this routine
- _ and newend not altered
-
- _ table entry setup
-
- ƒ #flag
- ¥ option
- » [tabpntr],y _ set mode of program
-
- _ put name into the table
-
- ₧ #0
- ƒ #name
- loadlop2 equ *
- ¥ prgname,x
- » [tabpntr],y
- Ü
- Ö
- Æ namelen
- â loadlop2
- ¥ #space
- loadlop8 equ *
- » [tabpntr],y
- Ö
- Ü
- Æ #maxlen
- â loadlop8
-
- _ save ram, start and end addresses
-
- ¥ ramused
- ƒ #ramprg
- » [tabpntr],y
- ¥ startram
- ƒ #strtadd
- » [tabpntr],y
- Ü
- ¥ startram+1
- » [tabpntr],y
- ƒ #endadd
- ¥ newend _ relying on reloc not changing them
- » [tabpntr],y
- Ü
- ¥ newend+1
- » [tabpntr],y
-
- _ set the priority value now
-
- ¥ pritemp
- ƒ #priority
- » [tabpntr],y
-
- _ save the zero and page one locations
- _ and put page 1 of new program available
-
- ƒ #zerooff
- ¥ zeropage
- » [tabpntr],y
- ƒ #ramprg
- ¥ [tabpntr],y
- » page1hi
- ƒ #oneoff
- ¥ pageone
- » [tabpntr],y
- » page1low
-
-
- _ set up the register info. This could be passed by the user or
- _ as an expansion allow file setup to define the information
- _ first though, the stack needs to be preserved...
-
- ┤
- ░ stktemp
-
- ₧ #$ff
- ╢
- ¥ newexec+1
- ú
- ¥ newexec
- ú
- ¥ #0
- ú _ status register
- ú _ A
- ú _ X
- ú _ Y
- ƒ #ramprg
- ¥ [tabpntr],y
- £ convram
- ú
-
- _ Save the new stack in the table ready to simulate a return of interrupt
-
- ƒ #regsp
- ┤
- ╡
- » [tabpntr],y
-
- _ restore the old page 1
-
- ¥ #osp1hi
- » page1hi
- ¥ #osp1low
- » page1low
- ₧ stktemp
- ╢
-
- ¥ option
- æ #prgnorun
- ê tryrun
- ¬
- tryrun equ *
- ¢ loadrun
-
- _ read name and priority, convert priority and store in the table
-
- readload equ *
- ₧ #0
- namelop1 equ *
- Ü
- ¥ charbuff,y _ Y points to next char
- æ #space
- à namelop1
- æ #comma
- à getpri
- æ #cr
- ê onpri
- ░ namelen
- ¥ #defpri _ default priority
- » pritemp
- ì
- ¬
- onpri equ *
- » prgname,x
- Ö
- Æ #16
- â namelop1
- ¥ #7
- £ dispmess
- ¼
- ¬
-
-
- getpri equ *
- ░ namelen
- ₧ #0
- namelop2 equ *
- Ü
- ¥ charbuff,y
- æ #cr
- à transfer
- » pritext,x
- Ö
- Æ #4
- â namelop2
- ¢ prierr
-
- _ convert priority now
-
- transfer equ *
- ╡
- ₧ #0
- ░ pritemp
- æ #2
- â ones
- æ #3
- â tens
- ¥ pritext
- £ conv
- æ #3
- ä prierr
- £ mult10
- £ mult10
- » pritemp
- Ö
- tens equ *
- ¥ pritext,x
- £ conv
- £ mult10
- ì
- Ç pritemp
- » pritemp
- Ö
- ones equ *
- ¥ pritext,x
- £ conv
- ì
- Ç pritemp
- » pritemp
- ì
- ¬
- prierr equ *
- ¥ #8
- £ dispmess
- ¼
- ¬
-
- _ above logic could not cope with 273 or 259 for example.
-
-
-
- _ Now locate the memory required. (check the end address in save and
- _ get the correct method for calculation of length required)
-
- _
- _ The following code is a modification to the load routine to load in
- _ extra information and then set up the relocation information
- _ the final part for relocation setup is completed when load is done.
- _
-
-
- loadmod equ *
- £ $e43e
- » oldadd
- £ $e43e
- » oldadd+1 _ set up for relocation
- £ $e43e
- » oldend
- £ $e43e
- » oldend+1
- £ $e43e
- » execadd
- £ $e43e
- » execadd+1
- £ procdata
- ä loderror
- ¢ $f2ba
-
- burstmod equ *
- £ $f503
- £ $f4ba
- » oldadd
- £ $f503
- £ $f4ba
- » oldadd+1
- £ $f503
- £ $f4ba
- » oldend
- £ $f503
- £ $f4ba
- » oldend+1
- £ $f503
- £ $f4ba
- » execadd
- £ $f503
- £ $f4ba
- » execadd+1
- Ñ
- ú
- æ #$1f
- ê notlast
- ¥ $a5
- ¼
- ½ #4
- » $a5
- notlast equ *
- £ procdata
- ä loderror
- ¢ $f434
- loderror equ *
- ¬ _ return to the calling loader with c=1
-
-
- _
- _ Note that end - start will give the correct length as the end is one
- _ more than it should be.
- _
-
- procdata equ *
- ¥ oldend
- ¼
- ½ oldadd
- » givelen
- ¥ oldend+1
- ½ oldadd+1
- » givelen+1
- ¥ #nostopt _ no options required
- £ locstor _ storage located for program.
- ä exitload
-
- _ Storage located ok, so set up the correct load information
- _ ie new start address and bank to load into
-
- ¥ startram
- » startlo _ setup for load
- » newstart _ setup for the relocation
- ¥ startram+1
- » starthi
- » newstart+1
- ¥ ramused
- £ convram
- » prglodbk
- » newram
-
- _
- _ find areas for page 0 and page 1. Done here because if you can't locate
- _ the storage, there isn't any point continuing the load.
- _
-
- ¥ #0
- » givelen
- ¥ #1 _ 1 page required.
- » givelen+1
- ¥ #pagbound _ just locate any old page
- £ locstor _ to store the ram of the pages.
- ä exitload
- ¥ startram+1
- » zeropage
- ¥ ramused
- » zeroram
- ¥ #0
- » givelen
- ¥ #1 _ 1 page required.
- » givelen+1
- ¥ #pagbound
- £ locstor
- ä exitload
- ¥ startram+1
- » pageone
- ¥ ramused
- » oneram
- ¬
-
- exitload equ *
-
- _
- _ Close all the files etc., this routine will set the carry flag
- _ and issue a return which will then return to the caller.
- _
-
- ¢ errload
-
- _
- _ convert a character to a value
- _
-
- conv equ *
- ¼
- ½ #50
- ¬
-
- _
- _ multiply A by 10 and return the value in A
- _
-
- Mult10 equ *
- é
- » temp
- é
- é
- é
- ì
- Ç temp
- ¬
-
- IEND
-
-
-
-
-