uint8 OBC1::read(unsigned addr) { addr &= 0x1fff; switch(addr) { case 0x1ff0: return ram_read(status.baseptr + (status.address << 2) + 0); case 0x1ff1: return ram_read(status.baseptr + (status.address << 2) + 1); case 0x1ff2: return ram_read(status.baseptr + (status.address << 2) + 2); case 0x1ff3: return ram_read(status.baseptr + (status.address << 2) + 3); case 0x1ff4: return ram_read(status.baseptr + (status.address >> 2) + 0x200); } return ram_read(addr); }
static ssize_t ram_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR uint8_t *buf) { FAR struct ram_dev_s *priv = (FAR struct ram_dev_s *)dev; off_t offset; off_t maxblock; size_t nbytes; DEBUGASSERT(dev && buf); /* Don't let the read exceed the size of the ram buffer */ maxblock = priv->nblocks * CONFIG_RAMMTD_BLKPER; if (startblock >= maxblock) { return 0; } if (startblock + nblocks > maxblock) { nblocks = maxblock - startblock; } /* Get the offset corresponding to the first block and the size * corresponding to the number of blocks. */ offset = startblock * CONFIG_RAMMTD_BLOCKSIZE; nbytes = nblocks * CONFIG_RAMMTD_BLOCKSIZE; /* Then read the data frp, RAM */ ram_read(buf, &priv->start[offset], nbytes); return nblocks; }
int main(void) { unsigned short addr1 = 0x1234; // the address for writing the ram char data[] = "Help, I'm stuck in the RAM!"; // the test message char read[] = "***************************"; // buffer for reading from ram char buf[100]; // buffer for comm. with the user unsigned char status; // used to verify we set the status NU32_Startup(); // cache on, interrupts on, LED/button init, UART init ram_init(); // check the ram status CS = 0; spi_io(0x5); // ram read status command status = spi_io(0); // the actual status CS = 1; sprintf(buf, "Status 0x%x\r\n",status); NU32_WriteUART3(buf); sprintf(buf,"Writing \"%s\" to ram at address 0x%x\r\n", data, addr1); NU32_WriteUART3(buf); // write the data to the ram ram_write(addr1, data, strlen(data) + 1); // +1, to send the '\0' character ram_read(addr1, read, strlen(data) + 1); // read the data back sprintf(buf,"Read \"%s\" from ram at address 0x%x\r\n", read, addr1); NU32_WriteUART3(buf); while(1) { ; } return 0; }
BYTE se5_roml_read(WORD addr) { if (addr < 0x9f00) { return roml_banks[(addr & 0x1fff) + (roml_bank << 13)]; } else { return ram_read(addr); /* return mem_read_without_ultimax(addr); */ } }
uint8 SMP::op_busread(uint16 addr) { unsigned result; switch(addr) { case 0xf0: //TEST -- write-only register return 0x00; case 0xf1: //CONTROL -- write-only register return 0x00; case 0xf2: //DSPADDR return status.dsp_addr; case 0xf3: //DSPDATA //0x80-0xff are read-only mirrors of 0x00-0x7f return dsp.read(status.dsp_addr & 0x7f); case 0xf4: //CPUIO0 case 0xf5: //CPUIO1 case 0xf6: //CPUIO2 case 0xf7: //CPUIO3 synchronize_cpu_force(); return cpu.port_read(addr); case 0xf8: //RAM0 return status.ram00f8; case 0xf9: //RAM1 return status.ram00f9; case 0xfa: //T0TARGET case 0xfb: //T1TARGET case 0xfc: //T2TARGET -- write-only registers return 0x00; case 0xfd: //T0OUT -- 4-bit counter value result = timer0.stage3_ticks; timer0.stage3_ticks = 0; return result; case 0xfe: //T1OUT -- 4-bit counter value result = timer1.stage3_ticks; timer1.stage3_ticks = 0; return result; case 0xff: //T2OUT -- 4-bit counter value result = timer2.stage3_ticks; timer2.stage3_ticks = 0; return result; } cdlInfo.set(eCDLog_AddrType_APURAM, addr); return ram_read(addr); }
BYTE expert_roml_read(WORD addr) { /* DBG(("EXPERT: set expert_roml_read: %x\n", addr)); */ if (cartmode == EXPERT_MODE_PRG) { return expert_ram[addr & 0x1fff]; } else if ((cartmode == EXPERT_MODE_ON) && expert_ramh_enabled) { return expert_ram[addr & 0x1fff]; } else { return ram_read(addr); } }
void SMP::disassemble_opcode(char *output) { char *s, t[512]; uint8 op, op0, op1; uint16 opw, opdp0, opdp1; s = output; if(in_opcode() == true) { strcpy(s, "..???? <SMP within opcode>"); return; } sprintf(s, "..%.4x ", regs.pc); op = ram_read(regs.pc); op0 = ram_read(regs.pc + 1); op1 = ram_read(regs.pc + 2); opw = (op0) | (op1 << 8); opdp0 = ((regs.p.p)?0x100:0x000) + op0; opdp1 = ((regs.p.p)?0x100:0x000) + op1; strcpy(t, " "); switch(op) { case 0x00: sprintf(t, "nop"); break; case 0x01: sprintf(t, "tcall 0"); break; case 0x02: sprintf(t, "set0 $%.3x", opdp0); break; case 0x03: sprintf(t, "bbs0 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x04: sprintf(t, "or a,$%.3x", opdp0); break; case 0x05: sprintf(t, "or a,$%.4x", opw); break; case 0x06: sprintf(t, "or a,(x)"); break; case 0x07: sprintf(t, "or a,($%.3x+x)", opdp0); break; case 0x08: sprintf(t, "or a,#$%.2x", op0); break; case 0x09: sprintf(t, "or $%.3x,$%.3x", opdp1, opdp0); break; case 0x0a: sprintf(t, "or1 c,$%.4x:%d", opw & 0x1fff, opw >> 13); break; case 0x0b: sprintf(t, "asl $%.3x", opdp0); break; case 0x0c: sprintf(t, "asl $%.4x", opw); break; case 0x0d: sprintf(t, "push p"); break; case 0x0e: sprintf(t, "tset $%.4x,a", opw); break; case 0x0f: sprintf(t, "brk"); break; case 0x10: sprintf(t, "bpl $%.4x", __relb(op0, 2)); break; case 0x11: sprintf(t, "tcall 1"); break; case 0x12: sprintf(t, "clr0 $%.3x", opdp0); break; case 0x13: sprintf(t, "bbc0 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x14: sprintf(t, "or a,$%.3x+x", opdp0); break; case 0x15: sprintf(t, "or a,$%.4x+x", opw); break; case 0x16: sprintf(t, "or a,$%.4x+y", opw); break; case 0x17: sprintf(t, "or a,($%.3x)+y", opdp0); break; case 0x18: sprintf(t, "or $%.3x,#$%.2x", opdp1, op0); break; case 0x19: sprintf(t, "or (x),(y)"); break; case 0x1a: sprintf(t, "decw $%.3x", opdp0); break; case 0x1b: sprintf(t, "asl $%.3x+x", opdp0); break; case 0x1c: sprintf(t, "asl a"); break; case 0x1d: sprintf(t, "dec x"); break; case 0x1e: sprintf(t, "cmp x,$%.4x", opw); break; case 0x1f: sprintf(t, "jmp ($%.4x+x)", opw); break; case 0x20: sprintf(t, "clrp"); break; case 0x21: sprintf(t, "tcall 2"); break; case 0x22: sprintf(t, "set1 $%.3x", opdp0); break; case 0x23: sprintf(t, "bbs1 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x24: sprintf(t, "and a,$%.3x", opdp0); break; case 0x25: sprintf(t, "and a,$%.4x", opw); break; case 0x26: sprintf(t, "and a,(x)"); break; case 0x27: sprintf(t, "and a,($%.3x+x)", opdp0); break; case 0x28: sprintf(t, "and a,#$%.2x", op0); break; case 0x29: sprintf(t, "and $%.3x,$%.3x", opdp1, opdp0); break; case 0x2a: sprintf(t, "or1 c,!$%.4x:%d", opw & 0x1fff, opw >> 13); break; case 0x2b: sprintf(t, "rol $%.3x", opdp0); break; case 0x2c: sprintf(t, "rol $%.4x", opw); break; case 0x2d: sprintf(t, "push a"); break; case 0x2e: sprintf(t, "cbne $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x2f: sprintf(t, "bra $%.4x", __relb(op0, 2)); break; case 0x30: sprintf(t, "bmi $%.4x", __relb(op0, 2)); break; case 0x31: sprintf(t, "tcall 3"); break; case 0x32: sprintf(t, "clr1 $%.3x", opdp0); break; case 0x33: sprintf(t, "bbc1 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x34: sprintf(t, "and a,$%.3x+x", opdp0); break; case 0x35: sprintf(t, "and a,$%.4x+x", opw); break; case 0x36: sprintf(t, "and a,$%.4x+y", opw); break; case 0x37: sprintf(t, "and a,($%.3x)+y", opdp0); break; case 0x38: sprintf(t, "and $%.3x,#$%.2x", opdp1, op0); break; case 0x39: sprintf(t, "and (x),(y)"); break; case 0x3a: sprintf(t, "incw $%.3x", opdp0); break; case 0x3b: sprintf(t, "rol $%.3x+x", opdp0); break; case 0x3c: sprintf(t, "rol a"); break; case 0x3d: sprintf(t, "inc x"); break; case 0x3e: sprintf(t, "cmp x,$%.3x", opdp0); break; case 0x3f: sprintf(t, "call $%.4x", opw); break; case 0x40: sprintf(t, "setp"); break; case 0x41: sprintf(t, "tcall 4"); break; case 0x42: sprintf(t, "set2 $%.3x", opdp0); break; case 0x43: sprintf(t, "bbs2 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x44: sprintf(t, "eor a,$%.3x", opdp0); break; case 0x45: sprintf(t, "eor a,$%.4x", opw); break; case 0x46: sprintf(t, "eor a,(x)"); break; case 0x47: sprintf(t, "eor a,($%.3x+x)", opdp0); break; case 0x48: sprintf(t, "eor a,#$%.2x", op0); break; case 0x49: sprintf(t, "eor $%.3x,$%.3x", opdp1, opdp0); break; case 0x4a: sprintf(t, "and1 c,$%.4x:%d", opw & 0x1fff, opw >> 13); break; case 0x4b: sprintf(t, "lsr $%.3x", opdp0); break; case 0x4c: sprintf(t, "lsr $%.4x", opw); break; case 0x4d: sprintf(t, "push x"); break; case 0x4e: sprintf(t, "tclr $%.4x,a", opw); break; case 0x4f: sprintf(t, "pcall $ff%.2x", op0); break; case 0x50: sprintf(t, "bvc $%.4x", __relb(op0, 2)); break; case 0x51: sprintf(t, "tcall 5"); break; case 0x52: sprintf(t, "clr2 $%.3x", opdp0); break; case 0x53: sprintf(t, "bbc2 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x54: sprintf(t, "eor a,$%.3x+x", opdp0); break; case 0x55: sprintf(t, "eor a,$%.4x+x", opw); break; case 0x56: sprintf(t, "eor a,$%.4x+y", opw); break; case 0x57: sprintf(t, "eor a,($%.3x)+y", opdp0); break; case 0x58: sprintf(t, "eor $%.3x,#$%.2x", opdp1, op0); break; case 0x59: sprintf(t, "eor (x),(y)"); break; case 0x5a: sprintf(t, "cmpw ya,$%.3x", opdp0); break; case 0x5b: sprintf(t, "lsr $%.3x+x", opdp0); break; case 0x5c: sprintf(t, "lsr a"); break; case 0x5d: sprintf(t, "mov x,a"); break; case 0x5e: sprintf(t, "cmp y,$%.4x", opw); break; case 0x5f: sprintf(t, "jmp $%.4x", opw); break; case 0x60: sprintf(t, "clrc"); break; case 0x61: sprintf(t, "tcall 6"); break; case 0x62: sprintf(t, "set3 $%.3x", opdp0); break; case 0x63: sprintf(t, "bbs3 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x64: sprintf(t, "cmp a,$%.3x", opdp0); break; case 0x65: sprintf(t, "cmp a,$%.4x", opw); break; case 0x66: sprintf(t, "cmp a,(x)"); break; case 0x67: sprintf(t, "cmp a,($%.3x+x)", opdp0); break; case 0x68: sprintf(t, "cmp a,#$%.2x", op0); break; case 0x69: sprintf(t, "cmp $%.3x,$%.3x", opdp1, opdp0); break; case 0x6a: sprintf(t, "and1 c,!$%.4x:%d", opw & 0x1fff, opw >> 13); break; case 0x6b: sprintf(t, "ror $%.3x", opdp0); break; case 0x6c: sprintf(t, "ror $%.4x", opw); break; case 0x6d: sprintf(t, "push y"); break; case 0x6e: sprintf(t, "dbnz $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x6f: sprintf(t, "ret"); break; case 0x70: sprintf(t, "bvs $%.4x", __relb(op0, 2)); break; case 0x71: sprintf(t, "tcall 7"); break; case 0x72: sprintf(t, "clr3 $%.3x", opdp0); break; case 0x73: sprintf(t, "bbc3 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x74: sprintf(t, "cmp a,$%.3x+x", opdp0); break; case 0x75: sprintf(t, "cmp a,$%.4x+x", opw); break; case 0x76: sprintf(t, "cmp a,$%.4x+y", opw); break; case 0x77: sprintf(t, "cmp a,($%.3x)+y", opdp0); break; case 0x78: sprintf(t, "cmp $%.3x,#$%.2x", opdp1, op0); break; case 0x79: sprintf(t, "cmp (x),(y)"); break; case 0x7a: sprintf(t, "addw ya,$%.3x", opdp0); break; case 0x7b: sprintf(t, "ror $%.3x+x", opdp0); break; case 0x7c: sprintf(t, "ror a"); break; case 0x7d: sprintf(t, "mov a,x"); break; case 0x7e: sprintf(t, "cmp y,$%.3x", opdp0); break; case 0x7f: sprintf(t, "reti"); break; case 0x80: sprintf(t, "setc"); break; case 0x81: sprintf(t, "tcall 8"); break; case 0x82: sprintf(t, "set4 $%.3x", opdp0); break; case 0x83: sprintf(t, "bbs4 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x84: sprintf(t, "adc a,$%.3x", opdp0); break; case 0x85: sprintf(t, "adc a,$%.4x", opw); break; case 0x86: sprintf(t, "adc a,(x)"); break; case 0x87: sprintf(t, "adc a,($%.3x+x)", opdp0); break; case 0x88: sprintf(t, "adc a,#$%.2x", op0); break; case 0x89: sprintf(t, "adc $%.3x,$%.3x", opdp1, opdp0); break; case 0x8a: sprintf(t, "eor1 c,$%.4x:%d", opw & 0x1fff, opw >> 13); break; case 0x8b: sprintf(t, "dec $%.3x", opdp0); break; case 0x8c: sprintf(t, "dec $%.4x", opw); break; case 0x8d: sprintf(t, "mov y,#$%.2x", op0); break; case 0x8e: sprintf(t, "pop p"); break; case 0x8f: sprintf(t, "mov $%.3x,#$%.2x", opdp1, op0); break; case 0x90: sprintf(t, "bcc $%.4x", __relb(op0, 2)); break; case 0x91: sprintf(t, "tcall 9"); break; case 0x92: sprintf(t, "clr4 $%.3x", opdp0); break; case 0x93: sprintf(t, "bbc4 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0x94: sprintf(t, "adc a,$%.3x+x", opdp0); break; case 0x95: sprintf(t, "adc a,$%.4x+x", opw); break; case 0x96: sprintf(t, "adc a,$%.4x+y", opw); break; case 0x97: sprintf(t, "adc a,($%.3x)+y", opdp0); break; case 0x98: sprintf(t, "adc $%.3x,#$%.2x", opdp1, op0); break; case 0x99: sprintf(t, "adc (x),(y)"); break; case 0x9a: sprintf(t, "subw ya,$%.3x", opdp0); break; case 0x9b: sprintf(t, "dec $%.3x+x", opdp0); break; case 0x9c: sprintf(t, "dec a"); break; case 0x9d: sprintf(t, "mov x,sp"); break; case 0x9e: sprintf(t, "div ya,x"); break; case 0x9f: sprintf(t, "xcn a"); break; case 0xa0: sprintf(t, "ei"); break; case 0xa1: sprintf(t, "tcall 10"); break; case 0xa2: sprintf(t, "set5 $%.3x", opdp0); break; case 0xa3: sprintf(t, "bbs5 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0xa4: sprintf(t, "sbc a,$%.3x", opdp0); break; case 0xa5: sprintf(t, "sbc a,$%.4x", opw); break; case 0xa6: sprintf(t, "sbc a,(x)"); break; case 0xa7: sprintf(t, "sbc a,($%.3x+x)", opdp0); break; case 0xa8: sprintf(t, "sbc a,#$%.2x", op0); break; case 0xa9: sprintf(t, "sbc $%.3x,$%.3x", opdp1, opdp0); break; case 0xaa: sprintf(t, "mov1 c,$%.4x:%d", opw & 0x1fff, opw >> 13); break; case 0xab: sprintf(t, "inc $%.3x", opdp0); break; case 0xac: sprintf(t, "inc $%.4x", opw); break; case 0xad: sprintf(t, "cmp y,#$%.2x", op0); break; case 0xae: sprintf(t, "pop a"); break; case 0xaf: sprintf(t, "mov (x)+,a"); break; case 0xb0: sprintf(t, "bcs $%.4x", __relb(op0, 2)); break; case 0xb1: sprintf(t, "tcall 11"); break; case 0xb2: sprintf(t, "clr5 $%.3x", opdp0); break; case 0xb3: sprintf(t, "bbc5 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0xb4: sprintf(t, "sbc a,$%.3x+x", opdp0); break; case 0xb5: sprintf(t, "sbc a,$%.4x+x", opw); break; case 0xb6: sprintf(t, "sbc a,$%.4x+y", opw); break; case 0xb7: sprintf(t, "sbc a,($%.3x)+y", opdp0); break; case 0xb8: sprintf(t, "sbc $%.3x,#$%.2x", opdp1, op0); break; case 0xb9: sprintf(t, "sbc (x),(y)"); break; case 0xba: sprintf(t, "movw ya,$%.3x", opdp0); break; case 0xbb: sprintf(t, "inc $%.3x+x", opdp0); break; case 0xbc: sprintf(t, "inc a"); break; case 0xbd: sprintf(t, "mov sp,x"); break; case 0xbe: sprintf(t, "das a"); break; case 0xbf: sprintf(t, "mov a,(x)+"); break; case 0xc0: sprintf(t, "di"); break; case 0xc1: sprintf(t, "tcall 12"); break; case 0xc2: sprintf(t, "set6 $%.3x", opdp0); break; case 0xc3: sprintf(t, "bbs6 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0xc4: sprintf(t, "mov $%.3x,a", opdp0); break; case 0xc5: sprintf(t, "mov $%.4x,a", opw); break; case 0xc6: sprintf(t, "mov (x),a"); break; case 0xc7: sprintf(t, "mov ($%.3x+x),a", opdp0); break; case 0xc8: sprintf(t, "cmp x,#$%.2x", op0); break; case 0xc9: sprintf(t, "mov $%.4x,x", opw); break; case 0xca: sprintf(t, "mov1 $%.4x:%d,c", opw & 0x1fff, opw >> 13); break; case 0xcb: sprintf(t, "mov $%.3x,y", opdp0); break; case 0xcc: sprintf(t, "mov $%.4x,y", opw); break; case 0xcd: sprintf(t, "mov x,#$%.2x", op0); break; case 0xce: sprintf(t, "pop x"); break; case 0xcf: sprintf(t, "mul ya"); break; case 0xd0: sprintf(t, "bne $%.4x", __relb(op0, 2)); break; case 0xd1: sprintf(t, "tcall 13"); break; case 0xd2: sprintf(t, "clr6 $%.3x", opdp0); break; case 0xd3: sprintf(t, "bbc6 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0xd4: sprintf(t, "mov $%.3x+x,a", opdp0); break; case 0xd5: sprintf(t, "mov $%.4x+x,a", opw); break; case 0xd6: sprintf(t, "mov $%.4x+y,a", opw); break; case 0xd7: sprintf(t, "mov ($%.3x)+y,a", opdp0); break; case 0xd8: sprintf(t, "mov $%.3x,x", opdp0); break; case 0xd9: sprintf(t, "mov $%.3x+y,x", opdp0); break; case 0xda: sprintf(t, "movw $%.3x,ya", opdp0); break; case 0xdb: sprintf(t, "mov $%.3x+x,y", opdp0); break; case 0xdc: sprintf(t, "dec y"); break; case 0xdd: sprintf(t, "mov a,y"); break; case 0xde: sprintf(t, "cbne $%.3x+x,$%.4x", opdp0, __relb(op1, 3)); break; case 0xdf: sprintf(t, "daa a"); break; case 0xe0: sprintf(t, "clrv"); break; case 0xe1: sprintf(t, "tcall 14"); break; case 0xe2: sprintf(t, "set7 $%.3x", opdp0); break; case 0xe3: sprintf(t, "bbs7 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0xe4: sprintf(t, "mov a,$%.3x", opdp0); break; case 0xe5: sprintf(t, "mov a,$%.4x", opw); break; case 0xe6: sprintf(t, "mov a,(x)"); break; case 0xe7: sprintf(t, "mov a,($%.3x+x)", opdp0); break; case 0xe8: sprintf(t, "mov a,#$%.2x", op0); break; case 0xe9: sprintf(t, "mov x,$%.4x", opw); break; case 0xea: sprintf(t, "not1 c,$%.4x:%d", opw & 0x1fff, opw >> 13); break; case 0xeb: sprintf(t, "mov y,$%.3x", opdp0); break; case 0xec: sprintf(t, "mov y,$%.4x", opw); break; case 0xed: sprintf(t, "notc"); break; case 0xee: sprintf(t, "pop y"); break; case 0xef: sprintf(t, "sleep"); break; case 0xf0: sprintf(t, "beq $%.4x", __relb(op0, 2)); break; case 0xf1: sprintf(t, "tcall 15"); break; case 0xf2: sprintf(t, "clr7 $%.3x", opdp0); break; case 0xf3: sprintf(t, "bbc7 $%.3x,$%.4x", opdp0, __relb(op1, 3)); break; case 0xf4: sprintf(t, "mov a,$%.3x+x", opdp0); break; case 0xf5: sprintf(t, "mov a,$%.4x+x", opw); break; case 0xf6: sprintf(t, "mov a,$%.4x+y", opw); break; case 0xf7: sprintf(t, "mov a,($%.3x)+y", opdp0); break; case 0xf8: sprintf(t, "mov x,$%.3x", opdp0); break; case 0xf9: sprintf(t, "mov x,$%.3x+y", opdp0); break; case 0xfa: sprintf(t, "mov $%.3x,$%.3x", opdp1, opdp0); break; case 0xfb: sprintf(t, "mov y,$%.3x+x", opdp0); break; case 0xfc: sprintf(t, "inc y"); break; case 0xfd: sprintf(t, "mov y,a"); break; case 0xfe: sprintf(t, "dbnz y,$%.4x", __relb(op0, 2)); break; case 0xff: sprintf(t, "stop"); break; } t[strlen(t)] = ' '; strcat(s, t); sprintf(t, "A:%.2x X:%.2x Y:%.2x SP:01%.2x YA:%.4x ", regs.a, regs.x, regs.y, regs.sp, regs.ya); strcat(s, t); sprintf(t, "%c%c%c%c%c%c%c%c", regs.p.n ? 'N' : 'n', regs.p.v ? 'V' : 'v', regs.p.p ? 'P' : 'p', regs.p.b ? 'B' : 'b', regs.p.h ? 'H' : 'h', regs.p.i ? 'I' : 'i', regs.p.z ? 'Z' : 'z', regs.p.c ? 'C' : 'c'); strcat(s, t); }
alwaysinline uint8 sSMP::op_busread(uint16 addr) { uint8 r; if((addr & 0xfff0) == 0x00f0) { //addr >= 0x00f0 && addr <= 0x00ff switch(addr) { case 0xf0: { //TEST -- write-only register r = 0x00; } break; case 0xf1: { //CONTROL -- write-only register r = 0x00; } break; case 0xf2: { //DSPADDR r = status.dsp_addr; } break; case 0xf3: { //DSPDATA //0x80-0xff are read-only mirrors of 0x00-0x7f r = dsp.read(status.dsp_addr & 0x7f); } break; case 0xf4: //CPUIO0 case 0xf5: //CPUIO1 case 0xf6: //CPUIO2 case 0xf7: { //CPUIO3 scheduler.sync_smpcpu(); r = cpu.port_read(addr & 3); } break; case 0xf8: { //??? r = status.smp_f8; } break; case 0xf9: { //??? r = status.smp_f9; } break; case 0xfa: //T0TARGET case 0xfb: //T1TARGET case 0xfc: { //T2TARGET -- write-only registers r = 0x00; } break; case 0xfd: { //T0OUT -- 4-bit counter value r = t0.stage3_ticks & 15; t0.stage3_ticks = 0; } break; case 0xfe: { //T1OUT -- 4-bit counter value r = t1.stage3_ticks & 15; t1.stage3_ticks = 0; } break; case 0xff: { //T2OUT -- 4-bit counter value r = t2.stage3_ticks & 15; t2.stage3_ticks = 0; } break; } } else { r = ram_read(addr); } return r; }
alwaysinline uint8 SMP::op_busread(uint16 addr) { uint8 r; if((addr & 0xfff0) == 0x00f0) { //00f0-00ff switch(addr) { case 0xf0: { //TEST -- write-only register r = 0x00; } break; case 0xf1: { //CONTROL -- write-only register r = 0x00; } break; case 0xf2: { //DSPADDR r = status.dsp_addr; } break; case 0xf3: { //DSPDATA //0x80-0xff are read-only mirrors of 0x00-0x7f r = dsp.read(status.dsp_addr & 0x7f); } break; case 0xf4: //CPUIO0 case 0xf5: //CPUIO1 case 0xf6: //CPUIO2 case 0xf7: { //CPUIO3 synchronize_cpu(); r = port.cpu_to_smp[addr & 3]; } break; case 0xf8: //PORT4 case 0xf9: { //PORT5 r = port.aux[addr & 1]; } break; case 0xfa: //T0TARGET case 0xfb: //T1TARGET case 0xfc: { //T2TARGET -- write-only registers r = 0x00; } break; case 0xfd: { //T0OUT -- 4-bit counter value r = t0.stage3_ticks & 15; t0.stage3_ticks = 0; } break; case 0xfe: { //T1OUT -- 4-bit counter value r = t1.stage3_ticks & 15; t1.stage3_ticks = 0; } break; case 0xff: { //T2OUT -- 4-bit counter value r = t2.stage3_ticks & 15; t2.stage3_ticks = 0; } break; } } else { r = ram_read(addr); } return r; }