Mercurial > hg > Members > kono > os9 > sbc09
changeset 10:2a1338b218bf
on going
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 05 Jul 2018 18:37:11 +0900 |
parents | cb7aa75418b8 |
children | ce7323f9b937 |
files | engine.c io.c os9/makerom.c |
diffstat | 3 files changed, 44 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/engine.c Thu Jul 05 16:00:19 2018 +0900 +++ b/engine.c Thu Jul 05 18:37:11 2018 +0900 @@ -40,9 +40,16 @@ extern long romstart; #ifdef USE_MMU -static inline Byte * mem0(Byte *iphymem, Word adr, Byte *immu) { + +Byte dummy; +static Byte * mem0(Byte *iphymem, Word adr, Byte *immu) { if (adr>=0xff00) return iphymem + memsize - 0x10000 + adr; // fixed area - return & iphymem[ ( immu[ (adr) >> 13 ] <<13 ) + ((adr) & 0x1fff )]; + int addr = (immu[ (adr) >> 13 ] <<13 ) + ((adr) & 0x1fff ); + if ( addr >= memsize ) { + dummy = 0; + return &dummy; + } + return & iphymem[ addr ]; }; #define mem(adr) (*mem0(iphymem, adr,immu)) #define GETWORD(a) ({Byte *phy = mem0(iphymem, a,immu); phy[0]<<8|phy[1];}) @@ -1143,7 +1150,13 @@ CLV SETDREG(tw) break; case 0xED: /*STD indexed */ tw=GETDREG; SETNZ16(tw) CLV +#ifdef USE_MMU + STOREAC((tw<<8)&0x0ff); eaddr++; + STOREAC(tw&0x0ff); + break; +#else SETWORD(eaddr,tw) break; +#endif case 0xEE: /* LDU (LDS) indexed */ tw=GETWORD(eaddr); CLV SETNZ16(tw) if(!iflag)iureg=tw; else isreg=tw;break; @@ -1188,7 +1201,13 @@ CLV SETDREG(tw) break; case 0xFD: /*STD ext */ EXTENDED tw=GETDREG; SETNZ16(tw) CLV +#ifdef USE_MMU + STOREAC((tw<<8)&0x0ff); eaddr++; + STOREAC(tw&0x0ff); + break; +#else SETWORD(eaddr,tw) break; +#endif case 0xFE: /* LDU (LDS) ext */ EXTENDED tw=GETWORD(eaddr); CLV SETNZ16(tw) if(!iflag)iureg=tw; else isreg=tw;break;
--- a/io.c Thu Jul 05 16:00:19 2018 +0900 +++ b/io.c Thu Jul 05 18:37:11 2018 +0900 @@ -497,7 +497,7 @@ Byte *phyadr = mem1(phymem,adr+i,mmu); prog = (char*)phyadr - adr; #endif - disasm(adr,adr+((i>len)?len:i)); + disasm(adr,adr+i-(len<16?16-len:0)); } } else { #ifdef USE_MMU
--- a/os9/makerom.c Thu Jul 05 16:00:19 2018 +0900 +++ b/os9/makerom.c Thu Jul 05 18:37:11 2018 +0900 @@ -63,6 +63,25 @@ putchar(*p & 0x7f); } +unsigned short +getword(unsigned char *ptr) +{ + return (ptr[0]<<8)+ptr[1]; +} + +void rewrite_vector(MPTR m,int top, unsigned char *adr,int count) +{ + // vector is a offset from $F100 (possibly os9p1 module address) + int offset = 0xf100-top; + for(int i=0;i<count;i++) { + int vec = getword(adr); + vec -= offset; + adr[0] = vec>>8; + adr[1] = vec&0xff; + adr += 2; + } +} + // calcurate position from the botton // avoid v09 IO map on 0xe000-0xe800 // os9p1 have to be last and at 0xf800 @@ -72,8 +91,10 @@ if (m->next==0) { if (level == 1) top = 0xf800; // OS9p1 - else + else { top = 0x10000-(m->size+0x80); + rewrite_vector(m,top,m->mod+getword(m->mod+2),7); + } } if (level==1 && !(( top+m->size < IOBASE ) || ( IOBASE+IOSIZE < top)) ) { top = IOBASE-m->size-1; @@ -91,12 +112,6 @@ return top; } -unsigned short -getword(unsigned char *ptr) -{ - return (ptr[0]<<8)+ptr[1]; -} - int main(int ac, char *av[]) {