; SCS1.ASM - runs IMSAI's SCS-1 monitor and assembler, from a tape dump, under CP/M 2.2 ; ; SCS-1 (the IMSAI Self-Contained System: monitor, line editor, 8080 assembler, memory file ; manager and breakpoint debugger) runs at 0050H and talks to an 8251 at ports 02H and 03H. ; This loader copies it to 0050H and sends its console through the CP/M BIOS instead, so it ; uses whatever console CP/M has: the Disk Jockey's, or the MIO's after MIO.COM. ; make.py fills IMAGE with the program from the tape's Intel HEX. ; ; SCS-1 keeps its workspace at 1000H-1123H and puts its RST 1 breakpoint jump at 0008H, so ; CP/M's jumps at 0000H and 0005H survive and EXEC 0000 returns to CP/M by a warm boot. LOADAT EQU 0050H ; where SCS-1 runs (its cold start) IMGLEN EQU 0DFAH ; 0050H-0E49H INIT EQU 0080H ; programs the 8251 INITEND EQU 0090H ; the first instruction after that CIN EQU 0129H ; reads a character into A and B COUT EQU 0136H ; writes the character in B SHIMS EQU 0010H ; RST 2-6 vectors, which neither CP/M nor SCS-1 uses ORG 100H JMP MOVE IMAGE: DS IMGLEN ; Copy SCS-1 down to 0050H. Copying upwards is safe: the destination is always below the ; source, and this code is above the end of the destination. MOVE: LXI H,IMAGE LXI D,LOADAT LXI B,IMGLEN MOVE1: MOV A,M STAX D INX H INX D DCX B MOV A,B ORA C JNZ MOVE1 ; The console routines go to 0010H, with the BIOS's CONIN and CONOUT filled in. LXI H,CONS LXI D,SHIMS MVI B,CONSLEN MOVE2: MOV A,M STAX D INX H INX D DCR B JNZ MOVE2 LHLD 1 ; the BIOS's warm boot entry, BIOS+3 LXI D,6 DAD D ; CONIN is BIOS+9 SHLD CIBIOS+1 INX H INX H INX H ; CONOUT is BIOS+0CH SHLD COBIOS+1 ; Patch SCS-1: skip the 8251 set-up, and send its two console routines to these. MVI A,0C3H ; JMP STA INIT STA CIN STA COUT LXI H,INITEND SHLD INIT+1 LXI H,CI SHLD CIN+1 LXI H,CO SHLD COUT+1 JMP LOADAT CONS: .PHASE SHIMS ; As SCS-1's own input routine: the character in A and B, bit 7 off. Other registers are kept. CI: PUSH H PUSH D PUSH B CIBIOS: CALL 0 POP B POP D POP H ANI 7FH MOV B,A RET ; As SCS-1's own output routine: sends B and returns with it in A, flags NZ and NC. CO: PUSH H PUSH D PUSH B MOV C,B COBIOS: CALL 0 POP B POP D POP H MVI A,1 ORA A MOV A,B RET .DEPHASE CONSLEN EQU $-CONS END