term equ $c00c00 t1 equ $c00c08 scsiadr equ $c00d00 IO equ 0 CD equ 1 REQ equ 2 SEL equ 3 MSG equ 4 ACK equ 5 BSY equ 6 ESC equ $1b stack equ $1400 totram equ $1404 buf equ $1408 rambeg equ $2400 rombeg equ $e00000 org 0 entry dc.l $1400 dc.l rombeg+main dc.l 0 dc.l 0 main move #$2700,sr move.l #stack,sp bsr init bsr vectors move.l $8,(sp) lea.l mem9(pc),a1 move.l a1,$8 move.l #0,a1 mem1 move.l a1,a0 adda.l #$1ffc,a1 move.l (a1),d0 move.l #$5aa55aa5,(a1) nop nop cmp.l #$5aa55aa5,(a1) bne.s mem9 move.l #$a55aa55a,(a1) nop nop cmp.l #$a55aa55a,(a1) bne.s mem9 move.l d0,(a1)+ bra.s mem1 mem9 move.l #stack,sp move.l (sp),$8 move.l a0,d0 move.l d0,(totram) lea.l mess(pc),a0 bsr printf loop lea.l prompt(pc),a0 bsr printf bsr readln cmpi.b #ESC,d0 beq.s loop1 tst d1 beq.s loop bsr docmd bra.s loop loop1 lea.l escstr(pc),a0 bsr printf bra.s loop vectors lea.l $400,a1 lea.l excptn(pc),a0 move #8,a2 move #$fd,d0 vec1 move.l a1,(a2) move #$4878,(a1)+ move a2,(a1)+ move #$4ef9,(a1)+ move.l a0,(a1)+ addq #4,a2 dbf d0,vec1 rts excptn move.l (sp)+,d0 lea.l oeps(pc),a0 bsr printf tst (sp)+ move.l (sp)+,d0 lea.l oeps2(pc),a0 bsr printf bra loop readln lea.l buf,a0 moveq #0,d0 moveq #0,d1 rdl1 bsr getch cmpi.b #ESC,d0 bne rdl4 rts rdl4 cmp.b #$0d,d0 bne.s rdl2 bsr putch move.b #$a,d0 bsr putch move.b #0,(a0)+ rts rdl2 cmpi.b #8,d0 bne.s rdl3 tst d1 beq.s rdl1 bsr putch move.b #$20,d0 bsr putch move.b #8,d0 bsr putch suba.l #1,a0 subq #1,d1 bra.s rdl1 rdl3 bsr putch move.b d0,(a0)+ addq #1,d1 bra.s rdl1 docmd clr d0 move d0,d1 lea.l cmdstr(pc),a1 do3 lea.l buf,a0 do2 move.b (a1)+,d0 beq.s do1 cmp.b (a0)+,d0 beq.s do2 do4 tst.b (a1)+ bne.s do4 addq #1,d1 bra.s do3 do1 cmp cmdcnt(pc),d1 bmi.s do5 lea.l errstr(pc),a0 bra printf do5 lsl.l #1,d1 move cmdtbl(pc,d1.w),d1 jmp cmdtbl(pc,d1.w) cmdcnt dc.w 10 cmdtbl dc.w diskio-cmdtbl dc.w dump-cmdtbl dc.w go-cmdtbl dc.w help-cmdtbl dc.w list-cmdtbl dc.w load-cmdtbl dc.w modify-cmdtbl dc.w read-cmdtbl dc.w write-cmdtbl dc.w boot-cmdtbl skipsp move.b (a0),d0 cmpi.b #' ',d0 bne.s skip9 adda #1,a0 bra.s skipsp skip9 rts getbyte moveq #2,d2 bra.s gethex getpar moveq #0,d2 gethex clr.l d0 geth1 move.b (a0)+,d1 subi.b #'0',d1 bmi.s geth9 cmpi.b #9,d1 ble.s geth2 andi.b #$df,d1 to upper subi.b #7,d1 cmpi.b #$a,d1 bmi.s geth8 cmpi.b #$f,d1 bgt.s geth8 geth2 lsl.l #4,d0 or.b d1,d0 subq #1,d2 bne.s geth1 geth8 move.l #-1,d1 geth9 rts dump bsr skipsp bsr getpar move.l d0,a1 dmp0 lea.l dmptxt1(pc),a0 bsr printf move #15,d7 16 regels dmp1 move.l a1,d0 bsr prhex move.b #' ',d0 bsr putch move.l a1,-(sp) move #15,d6 16 bytes/regel dmp2 move.b #' ',d0 bsr putch move.b (a1)+,d0 bsr prbyt dbra d6,dmp2 move.l (sp)+,a1 move.b #' ',d0 bsr putch bsr putch move #15,d6 and character print dmp3 move.b (a1)+,d0 cmpi.b #$20,d0 bcs.s dmp4 cmpi.b #$7f,d0 bcs.s dmp5 dmp4 move.b #'.',d0 dmp5 bsr putch dbra d6,dmp3 bsr crlf dbra d7,dmp1 bsr readln cmpi.b #ESC,d0 beq.s dmp9 tst d1 beq dmp0 dmp9 rts dmptxt1 dc.b 'Address 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 2 4 6 8 A C E',$d,$a dc.b '---------------------------------------------------------------------------',$d,$a,$0 * '00001000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ modify bsr skipsp bsr getpar get address move.l d0,a1 mod0 move.l a1,d0 lea.l modtxt1(pc),a0 bsr printf move.b (a1),d0 bsr prbyt move.b #' ',d0 bsr putch move.b #'?',d0 bsr putch bsr readln cmpi.b #ESC,d0 beq.s mod9 tst d1 bne.s mod1 addq #1,a1 bra.s mod0 mod1 lea.l buf,a0 bsr skipsp bsr getpar move.b d0,(a1)+ bra.s mod0 mod9 bsr crlf rts modtxt1 dc.b '%x: ',$0 go bsr skipsp bsr getpar move.l d0,a0 jmp (a0) help lea.l hlpstr(pc),a0 bsr printf rts load bsr skipsp moveq #0,d2 entire parameter bsr getpar get loadaddress in d0 move.l d0,a5 ldsrec lea.l buf,a0 move.l a0,-(sp) bsr readln move.l (sp)+,a0 ld1 move.b (a0)+,d0 cmp.b #'S',d0 bne.s ld1 ldhdr move.b (a0)+,d0 cmp.b #'0',d0 beq.s ldsrec skip S0 lds1 cmp.b #'1',d0 is it S1 bne.s lds9 moveq #0,d7 clr chksum bsr getbyte bytecount (not included) add d0,d7 move d0,d3 bsr getbyte address add d0,d7 subq #1,d3 bsr getbyte add d0,d7 subq #1,d3 lds1a bsr getbyte get byte add d0,d7 move.b d0,(a5)+ subq #1,d3 cmpi #1,d3 only chksum left? bne.s lds1a ldchk bsr getbyte not d7 cmp.b d0,d7 bne.s ldserr bra ldsrec lds9 cmp.b #'9',d0 beq.s ldsend ldserr lea.l srecerr(pc),a0 bsr printf ldsend rts kernel dc.b 'kernel',$0 hdr dc.b 'Module found at $%x: ',$0 hdr2 dc.b $d,$a,$0 list lea.l rambeg,a0 list1 move #$4afc,d0 cmpa.l (totram),a0 beq.s list9 cmp (a0)+,d0 bne.s list1 move.l a0,a1 move #22,d1 list11 move (a1)+,d2 eor d2,d0 dbf d1,list11 not d0 bne.s list1 move.l a0,-(sp) suba.l #2,a0 move.l a0,-(sp) move.l a0,d0 lea.l hdr(pc),a0 bsr printf move.l (sp)+,a0 adda.l $c(a0),a0 bsr printf lea.l hdr2(pc),a0 bsr printf move.l (sp)+,a0 bra.s list1 list9 clr d0 rts boot bsr skipsp bsr getpar tst.l d0 beq.s bootdsk move.l d0,a0 bra boot3 bootdsk lea.l -16(a7),a7 move.l a7,a5 move.l #0,(a5) sector 0 move.b #8,(a5) read move.b #1,4(a5) 1 sector move.b #0,5(a5) move.l #rambeg,a0 bsr scsi bcc.s bootd1 move d1,d0 lea.l sc1txt(pc),a0 bsr printf bra.s bootd9 bootd1 moveq #0,d0 move $18(a0),d0 length bne.s bootd2 lea.l lenerr(pc),a0 bsr printf bra.s bootd9 bootd2 move.l $14(a0),(a5) os9boot sector move.b #8,(a5) read add #$1ff,d0 andi #$ff00,d0 rounded length move.l d0,d6 lsr.l #8,d6 # sectors (512 byte!!) lsr.l #1,d6 move.b d6,4(a5) # sectors move.b #0,5(a5) move.l (totram),a0 top of ram * suba.l #$1000,a0 top occupied by boot (TEMP!) suba.l d0,a0 bsr scsi bcc.s boot3 move d1,d0 lea.l sc1txt(pc),a0 bsr printf bootd9 adda.l #16,a7 rts boot3 move.l a0,-(sp) move.l a0,d0 lea.l kertxt(pc),a0 bsr printf move.l (sp)+,a0 boot4 move.l a0,a3 os9boot startadr move.l a0,d0 move.l (totram),d6 sub.l d0,d6 amount of ram up from OS9Boot move.l #0,a0 clear all ram up to os9boot clr1 clr.l (a0)+ cmp.l a3,a0 bne.s clr1 move.l #stack,$0 lea.l main(pc),a1 move.l a1,$4 move.l #$400,a5 bsr vectors move.l #rambeg,a4 clr.l (a4) linked list, one element move.l a3,d0 total ram left sub.l a4,d0 move.l d0,4(a4) size lea.l stack,a7 move.l a7,a6 move.l #0,-(a7) last rom segment move.l d6,-(a7) rom length move.l a3,-(a7) start rom move.l #20,d1 cpu type clr.l d2 debug flag move.l d2,d3 startup method move.l d2,d4 move.l d2,d5 move.l d2,d6 move.l d2,d7 lea.l trip(pc),a0 garbage move.l a0,$118 move.l d2,a0 lea.l jmptbl(pc),a1 move.l d2,a2 add.l 48(a3),a3 jmp (a3) trip rte jmptbl jmp main(pc) jmp main(pc) jmp putch(pc) jmp main(pc) jmp main(pc) printf movem.l d0-d7/a0-a6,-(sp) pr1 move.b (a0)+,d0 beq.s pr9 cmpi.b #'%',d0 bne.s pr2 move.b (a0)+,d0 cmpi.b #'x',d0 hex (long) bne.s pr5 move.l (sp),d0 bsr prhex bra.s pr1 pr5 cmpi.b #'b',d0 byte bne.s pr3 move.l (sp),d0 bsr prbyt bra.s pr1 pr3 cmpi.b #'s',d0 bne.s pr4 move.l a0,-(sp) move.l d0,a0 bsr printf move.l (sp)+,a0 bra.s pr1 pr4 cmpi.b #'%',d0 bne.s pr1 pr2 bsr putch bra.s pr1 pr9 movem.l (sp)+,d0-d7/a0-a6 rts prhex movem.l d6-d7,-(sp) moveq #7,d7 move.l d0,d1 prhex1 clr.l d0 moveq #3,d6 prhex3 roxl.l #1,d1 roxl #1,d0 dbra d6,prhex3 bsr prnib dbra d7,prhex1 movem.l (sp)+,d6-d7 rts prbyt move.l d0,d1 lsr.b #4,d0 bsr prnib move.b d1,d0 prnib and.b #$f,d0 add.b #$30,d0 cmpi.b #$3a,d0 bmi.s prnib2 addi.b #$7,d0 prnib2 bsr putch move.l d1,d0 rts crlf move.b #$0d,d0 bsr putch move.b #$0a,d0 bsr putch rts diskio lea.l -16(a7),a7 move.l a7,a5 bsr skipsp bsr getpar ptr to CDB move.l d0,a5 bsr skipsp bsr getpar move.l d0,a0 ptr to data bsr scsi bcc.s disk9 move d1,d0 lea.l sc1txt(pc),a0 bsr printf disk9 adda.l #16,a7 rts write lea.l -16(a7),a7 move.l a7,a5 bsr skipsp bsr getpar LSN move.l d0,(a5) move.b #$0a,(a5) bsr skipsp bsr getpar # sectors move.b d0,4(a5) move.b #0,5(a5) bsr skipsp bsr getpar ptr move.l d0,a0 bsr scsi bcc.s write9 move d1,d0 lea.l sc1txt(pc),a0 bsr printf write9 adda.l #16,a7 rts read lea.l -16(a7),a7 move.l a7,a5 bsr skipsp bsr getpar LSN move.l d0,(a5) move.b #8,(a5) scsi read bsr skipsp bsr getpar # sectors move.b d0,4(a5) move.b #0,5(a5) bsr skipsp bsr getpar ptr move.l d0,a0 bsr scsi bcc.s read9 move d1,d0 lea.l sc1txt(pc),a0 bsr printf read9 adda.l #16,a7 rts scsi movem.l d0/a0/a5,-(sp) lea.l scsiadr,a4 move.l #$10000,d1 move.b #1,4(a4) scsel subi.l #1,d1 bne.s scsel1 tst.b 4(a4) reset SEL moveq #-1,d1 ori #1,sr bra scsi9 scsel1 move.b 2(a4),d7 btst #REQ,d7 beq.s scsel sccmd move.b 2(a4),d7 btst #REQ,d7 beq.s sccmd btst #CD,d7 beq.s scdata btst #IO,d7 bne.s scdata move.b (a5)+,d0 move.b d0,(a4) bra.s sccmd scdata move.b 2(a4),d7 btst #REQ,d7 beq.s scdata btst #IO,d7 is it read or write? beq.s scwr1 bra.s scrd1 scrd move.b 2(a4),d7 readloop btst #REQ,d7 beq.s scrd scrd1 btst #CD,d7 bne.s scstat move.b (a4),d0 move.b d0,(a0)+ bra.s scrd scwr move.b 2(a4),d7 write loop btst #REQ,d7 beq.s scwr scwr1 btst #CD,d7 bne.s scstat move.b (a0)+,d0 move.b d0,(a4) bra.s scwr scstat move.b (a4),d1 get statusbyte scstat3 move.b 2(a4),d7 btst #REQ,d7 beq.s scstat3 move.b (a4),d2 get 2nd byte scsi8 tst.b d1 beq.s scsi9 ori #1,sr scsi9 movem.l (sp)+,d0/a0/a5 rts init lea.l term,a3 move.b #$7d,d0 term: 9k6 bsr initerm lea.l t1,a3 move.b #$7f,d0 t1: 38k4 bsr initerm lea.l tstrdy(pc),a5 moveq #0,d0 bsr scsi bcc.s init9 bsr scsi bcc.s init9 lea.l notrdy(pc),a0 bsr printf init9 rts tstrdy dc.b 0,0,0,0,0,0 initerm move.b #$00,6(a3) bsr delay move.b #$4e,4(a3) 1 stop, no paririty, 8 bit, 16x bsr delay move.b d0,4(a3) TxC/RxC internal, 16x bsr delay move.b #$36,6(a3) rts putch movem.l a3,-(sp) lea.l term,a3 move.b #$37,6(a3) bsr delay move.b d0,(a3) put1 bsr delay btst #0,2(a3) beq.s put1 bsr delay move.b #$36,6(a3) movem.l (sp)+,a3 rts getch movem.l a3,-(sp) lea.l term,a3 getc1 bsr delay btst #1,2(a3) beq.s getc1 bsr delay move.b (a3),d0 movem.l (sp)+,a3 rts delay rts dumpreg movem.l a0/d0,-(sp) lea.l d0txt(pc),a0 bsr printf move.l d1,d0 lea.l d1txt(pc),a0 bsr printf move.l d2,d0 lea.l d2txt(pc),a0 bsr printf move.l d3,d0 lea.l d3txt(pc),a0 bsr printf move.l d4,d0 lea.l d4txt(pc),a0 bsr printf move.l d5,d0 lea.l d5txt(pc),a0 bsr printf move.l d6,d0 lea.l d6txt(pc),a0 bsr printf move.l d7,d0 lea.l d7txt(pc),a0 bsr printf move.l a0,d0 lea.l a0txt(pc),a0 bsr printf move.l a1,d0 lea.l a1txt(pc),a0 bsr printf move.l a2,d0 lea.l a2txt(pc),a0 bsr printf move.l a3,d0 lea.l a3txt(pc),a0 bsr printf move.l a4,d0 lea.l a4txt(pc),a0 bsr printf move.l a5,d0 lea.l a5txt(pc),a0 bsr printf move.l a6,d0 lea.l a6txt(pc),a0 bsr printf move.l a7,d0 lea.l a7txt(pc),a0 bsr printf movem.l (sp)+,a0/d0 rts d0txt dc.b 'D0: %x ',0 d1txt dc.b 'D1: %x ',0 d2txt dc.b 'D2: %x ',0 d3txt dc.b 'D3: %x ',$d,$a,0 d4txt dc.b 'D4: %x ',0 d5txt dc.b 'D5: %x ',0 d6txt dc.b 'D6: %x ',0 d7txt dc.b 'D7: %x ',$d,$a,0 a0txt dc.b 'A0: %x ',0 a1txt dc.b 'A1: %x ',0 a2txt dc.b 'A2: %x ',0 a3txt dc.b 'A3: %x ',$d,$a,0 a4txt dc.b 'A4: %x ',0 a5txt dc.b 'A5: %x ',0 a6txt dc.b 'A6: %x ',0 a7txt dc.b 'A7: %x ',$d,$a,0 mess dc.b $d,$a,'OS-9/68k System bootstrap',$d,$a dc.b 'Memsize $%x',$d,$a,$a,$0 oeps dc.b $d,$a,'Exception Error at vector: $%x ',$0 oeps2 dc.b 'at address: $%x',$d,$a,$0 oeps3 dc.b 'Fatal System Error; rebooting system',$d,$a,$a,$0 notrdy dc.b 'Warning: Disk not ready: $%b',$d,$a,$0 prompt dc.b '> ',$0 escstr dc.b $d,$a,$a,'Escape',$d,$a,$0 hlpstr dc.b 'dump
',$d,$a dc.b 'go ',$d,$a dc.b 'help',$d,$a dc.b 'list',$d,$a dc.b 'load ',$d,$a dc.b 'modify ',$d,$a dc.b 'read