# HG changeset patch # User Shinji KONO # Date 1530760026 -32400 # Node ID 96a067cf4c4f9629415774cfea045318160ebf6a # Parent a6db579d8c11d8b6faae17c7b663e5c417df1a33 level2 rom done diff -r a6db579d8c11 -r 96a067cf4c4f a09.c --- a/a09.c Thu Jul 05 02:00:14 2018 +0900 +++ b/a09.c Thu Jul 05 12:07:06 2018 +0900 @@ -181,21 +181,31 @@ int os9 = 0; // os9 flag int prevloc = 0; -/* Symbol categories. - 0 Constant value (from equ). - 1 Variable value (from set) - 2 Address within program module (label). - 3 Variable containing address. - 4 Adress in other program module (extern) - 5 Variable containing external address. - 6 Unresolved address. - 7 Variable containing unresolved address. - 8 Public label. - 9 Macro definition. - 10 Public label (yet undefined). - 11 parameter name. - 12 local label. - 13 empty. +/* expression categories... + ECORD all zeros is ordinary constant. + ECADR bit 1 indicates address within module. + ECEXT bit 2 indicates external address. + ECLBL bit 3 public label + ECABS bit 4 indicates this can't be relocated if it's an address. + ECNEG bit 5 indicates address (if any) is negative. +*/ + + +/* Symbol categories. exprcat ( symcat & 0xe ) + 0 SCC Constant value (from equ). ECORD + 1 SCV Variable value (from set) ECORD + 2 SCC__ADR Address within program module (label). ECADR + 3 SCV__ADR Variable containing address. ECADR + 4 SC_E_ADR Adress in other program module (extern) ECEXT + 5 SCVE_ADR Variable containing external address. ECEXT + 6 SCU _ADR Unresolved address. ECEXT+ECADR + 7 SCV_UADR Variable containing unresolved address. ECEXT+ECADR + 8 SC___LBL Public label. ECLBL + 9 SCMACRO Macro definition. xxx + 10 SCU__LBL Public label (yet undefined). ECADR+ECLBL + 11 SCPARAM parameter name. ECADR+ECLBL + 12 SCLOCAL local label. ECEXT+ECLBL + 13 SCEMPTY empty. xxx */ struct symrecord symtable[NLABELS]; @@ -431,15 +441,6 @@ return p->value; } -/* expression categories... - all zeros is ordinary constant. - bit 1 indicates address within module. - bit 2 indicates external address. - bit 4 indicates this can't be relocated if it's an address. - bit 5 indicates address (if any) is negative. -*/ - - short scanfactor() { @@ -934,9 +935,9 @@ if(offs<-128||offs>=128||opsize==3||unknown||!certain) { if((!unknown)&&opsize==2&&(offs<-128||offs>=128) ) error|=16; - offs--; - opsize=3; - postbyte++; + // offs--; + // opsize=3; + // postbyte++; } putbyte(postbyte); if (debug) fprintf(stderr,"DEBUG: doaddress: mode=%d, opsize=%d, error=%d, postbyte=%02X, operand=%04X offs=%d\n",mode,opsize,error,postbyte,operand,offs); diff -r a6db579d8c11 -r 96a067cf4c4f os9/level2/Makefile --- a/os9/level2/Makefile Thu Jul 05 02:00:14 2018 +0900 +++ b/os9/level2/Makefile Thu Jul 05 12:07:06 2018 +0900 @@ -3,17 +3,17 @@ SRCDIR=../../CoCoOS9/level2v3/MODULES -all : ioman pdisk init os9p1 os9p2 os9p3_perr os9p4_regdump pipe pipeman pipeman_named piper rbf scf term pty d0 d1 clock +all : ioman pdisk init os9p1 os9p2 os9p3_perr os9p4_regdump pipe pipeman pipeman_named piper rbf scf term pty d0 d1 clock vector clean : - rm -f ioman pdisk init os9p1 os9p2 os9p3_perr os9p4_regdump pipe pipeman pipeman_named piper rbf scf term pty d0 d1 clock + rm -f ioman pdisk init os9p1 os9p2 os9p3_perr os9p4_regdump pipe pipeman pipeman_named piper rbf scf term pty d0 d1 clock vector -pdisk : +pdisk : ../modules/pdisk.asm $(A09) ../modules/pdisk.asm -o pdisk -init : - $(A09) ../modules/init.asm -o init +init : init.asm + $(A09) init.asm -o init term : $(A09) pty-dd.asm -o term @@ -30,6 +30,8 @@ pty : $(A09) ../modules/pty.asm -o pty +vector : vector.asm + $(A09) vector.asm -o vector os9p1 : $(A09) ${SRCDIR}/os9p1.asm -o os9p1 diff -r a6db579d8c11 -r 96a067cf4c4f os9/level2/init.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os9/level2/init.asm Thu Jul 05 12:07:06 2018 +0900 @@ -0,0 +1,28 @@ +* OS9 standard init modul. + nam Init + ttl os9 system module + + ifp1 + use os9defs + endc +null set $0000 +tylg set Systm+$00 +atrv set ReEnt+rev +rev set $01 + mod eom,initnam,tylg,atrv + fcb 0 + fdb $D000 + fcb $0C + fcb $0C + fdb sysgo + fdb null system device (sysdev) + fdb systerm + fdb null bootstrap module (bootst) +initnam fcs "Init" +sysgo fcs "SysGo" +sysdev fcs "/D0" +systerm fcs "/Term" +bootst fcs "Boot" + emod +eom equ * + diff -r a6db579d8c11 -r 96a067cf4c4f os9/level2/vector.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os9/level2/vector.asm Thu Jul 05 12:07:06 2018 +0900 @@ -0,0 +1,25 @@ + org $ffd0 +entry equ $f100 + +reset clra + tfr a,dp + ldx $ff90 + sta $10,x + lda #$3f + sta $17,x + lda #1 + sta 1,x + jmp [size+0x80); } - if (!(( top+m->size < IOBASE ) || ( IOBASE+IOSIZE < top)) ) { + if (level==1 && !(( top+m->size < IOBASE ) || ( IOBASE+IOSIZE < top)) ) { top = IOBASE-m->size-1; m->ioflag = 1; - // printf("*"); +#ifdef DEBUG + printf("*"); +#endif } m->location = top; - // printf("mod "); - // printOs9Str(m->name); - // printf(" \t: 0x%x - 0x%x\n",top, top + m->size); +#ifdef DEBUG + printf("mod "); + printOs9Str(m->name); + printf(" \t: 0x%x - 0x%x\n",top, top + m->size); +#endif return top; } +unsigned short +getword(unsigned char *ptr) +{ + return (ptr[0]<<8)+ptr[1]; +} + int main(int ac, char *av[]) { @@ -127,9 +139,11 @@ printf("\n\n"); pos = start; + struct os9module *os9p1 = 0; for(struct os9module *cur = root.next; cur ; cur = cur->next ) { // last module have to os9p1 if ( cur->next == 0 ) { + os9p1 = cur; if ( level==1 ) { for(; pos < 0xf800 ; pos++) { // os9p1 begins at 0xf800 fputc(0xff,romfile); @@ -145,7 +159,10 @@ printOs9Str(cur->name); fwrite(cur->mod, cur->size, 1, romfile); printf(" \t: 0x%x - 0x%x\n",pos, pos + cur->size-1); - // printf(" \t: 0x%x - 0x%x : 0x%lx \n",pos, pos + cur->size, ftell(romfile)+start); +#ifdef DEBUG + printf(" \t: 0x%x \n",cur->location); + printf(" \t: 0x%x - 0x%x : 0x%lx \n",pos, pos + cur->size, ftell(romfile)+start); +#endif pos = pos+cur->size; if (cur->ioflag) { if (level==1) { @@ -153,11 +170,7 @@ fputc(0xff,romfile); } printf("*"); - } else { - for(; pos < IOBASE + IOSIZE - 2*7 ; pos++) { - fputc(0xff,romfile); - } - } + } } } printf("os9 end %x\n",pos); @@ -173,15 +186,31 @@ fputword(0xF841,romfile); fputword(0xF876,romfile); } else { - vectable = 0x10000 - 2*6; - for( ; poslocation); +#endif + printf("os9entry %x\n",os9p1->location+getword(os9p1->mod+9)); + + fputword(os9p1->location+getword(os9p1->mod+9),romfile); // os9p1 entry point + unsigned short vec = os9p1->location+os9p1->size + 15; + fputword(vec,romfile); + fputword(vec+3,romfile); + fputword(vec+6,romfile); + + fputword(vec+9,romfile); + fputword(vec+12,romfile); + fputword(vec+15,romfile); + fputword(0xffe0,romfile); } if (level==1) printf("boot rom from 0x%lx\n",0x10000-ftell(romfile)); diff -r a6db579d8c11 -r 96a067cf4c4f os9/os9disass.c --- a/os9/os9disass.c Thu Jul 05 02:00:14 2018 +0900 +++ b/os9/os9disass.c Thu Jul 05 12:07:06 2018 +0900 @@ -1110,7 +1110,7 @@ int offset; offset = prog[pc+1]; - fprintf(fp,"%0.2X %0.2X %s%s $%0.2X", + fprintf(fp,"%0.2X %0.2X %s%s <$%0.2X", code, offset, suffix, op->name, offset); return op->bytes; } @@ -1307,14 +1307,14 @@ offset = (prog[pc+2]+pc+3) & 0xFFFF; s = "<"; fprintf(fp,"%0.2X %0.2X %0.2X %s%s %s$%0.2X,PCR", - code, postbyte, prog[pc+2], suffix, op->name, s, pc+3+offset+adoffset); + code, postbyte, prog[pc+2], suffix, op->name, s, offset+adoffset); extrabytes = 1; break; case 0x0d : offset = (prog[pc+2] * 256 + prog[pc+3]+pc+4) & 0xFFFF; s = ">"; fprintf(fp,"%0.2X %0.2X %0.2X %0.2X %s%s %s$%0.4X,PCR", - code, postbyte, prog[pc+2], prog[pc+3], suffix, op->name, s, offset+pc+4+adoffset); + code, postbyte, prog[pc+2], prog[pc+3], suffix, op->name, s, offset+adoffset); extrabytes = 2; break; case 0x0e : @@ -1387,14 +1387,14 @@ offset = (prog[pc+2]+pc+3) & 0xFFFF; s = "<"; fprintf(fp,"%0.2X %0.2X %0.2X %s%s [%s$%0.2X,PCR]", - code, postbyte, prog[pc+2], suffix, op->name, s, offset+pc+2+adoffset); + code, postbyte, prog[pc+2], suffix, op->name, s, offset+adoffset); extrabytes = 1; break; case 0x1d : offset = (prog[pc+2] * 256 + prog[pc+3]+pc+4) & 0xFFFF; s = ">"; fprintf(fp,"%0.2X %0.2X %0.2X %0.2X %s%s [%s$%0.4X,PCR]", - code, postbyte, prog[pc+2], prog[pc+3], suffix, op->name, s, offset+pc+3+adoffset); + code, postbyte, prog[pc+2], prog[pc+3], suffix, op->name, s, offset+adoffset); extrabytes = 2; break; case 0x1e : @@ -1639,7 +1639,8 @@ } sscanf(argv[2],"%x",&start); start -= adoffset; - sscanf(argv[3],"%x",&end); end -= adoffset; + sscanf(argv[3],"%x",&end); end -= adoffset; + printf("disass %x - %x\n",start,end); fp = stdout;