title 'External Code Up-Load Program Module' ;---------------------------------------------------------------- ; This is the CODE LOAD routine. It must get the next ascii ; character and perform the command requested by it. ; With this routine, other programs can load code into the ; computer running this program then run them. ; ; Written by Richard Holmes 12/12/1987 ; Last Update by Richard Holmes 12/12/1987 ;---------------------------------------------------------------- ; maclib z80 ; public ext$ldr extrn con$inp,con$out,con$ist ; cr equ 0dh lf equ 0ah esc equ 01bh ; ext$ldr: call con$inp ; Get character cpi 'l' jz cl$l cpi 'L' jz cl$l ; Get data to be loaded ; cpi 'r' jz 0 cpi 'R' jz 0 ; Reset CPU if a reset command ; cpi 'g' jz cl$g cpi 'G' ; Goto an address and run. jz cl$g ; ret ; erdisp: mvi a,'?' jmp con$out ; ;---------------------------------------------------------------- ; Load Code ; ; Get an address to be loaded, a number of bytes, then the ; data to load from the user. ;---------------------------------------------------------------- ; cl$l: call con$inp ; Low destination mov l,a call con$inp mov h,a ; High destination call con$inp mov c,a ; Low counter call con$inp mov b,a ; High counter ; Now the data mov a,c ora b jrz erdisp ; No data = an error ; ; Else fetch BC bytes from the user, stuff into RAM at mHL. ; mvi e,0 ; Clear the seed. gd$loop: call con$inp mov m,a inx h ; -> next location in ram add e mov e,a ; Update the seed ; dcx b mov a,b ora c jrnz gd$loop ; ; Get the ending cariage return. If not a return then abort ; ELSE send back the checksum. call con$inp cpi cr rnz ; Exit if not a CR mov a,e call con$out ; ; After sending the checksum binary byte, wait for the user to send ; the next byte. If an '@' then we can go again else abort back ; to the warm start loop point. ; call con$inp cpi '@' jz ext$ldr ret ; ; ;---------------------------------------------------------------- ; Get an address from the user and GOTO it. ;---------------------------------------------------------------- ; cl$g: call con$inp mov l,a ; Low address first call con$inp mov h,a ; High address call con$inp cpi cr jnz erdisp ; Error if not a CR at the end of it pchl ; Else goto the address ; end ; ; -- Of Program -- ;