2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto readpc() -> uint8 {
|
|
|
|
return read((regs.pc.b << 16) + regs.pc.w++);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto readstack() -> uint8 {
|
2010-08-09 13:28:56 +00:00
|
|
|
regs.e ? regs.s.l++ : regs.s.w++;
|
2016-03-26 01:56:15 +00:00
|
|
|
return read(regs.s.w);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto readstackn() -> uint8 {
|
|
|
|
return read(++regs.s.w);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto readaddr(uint32 addr) -> uint8 {
|
|
|
|
return read(addr & 0xffff);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto readlong(uint32 addr) -> uint8 {
|
|
|
|
return read(addr & 0xffffff);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto readdbr(uint32 addr) -> uint8 {
|
|
|
|
return read(((regs.db << 16) + addr) & 0xffffff);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto readpbr(uint32 addr) -> uint8 {
|
|
|
|
return read((regs.pc.b << 16) + (addr & 0xffff));
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto readdp(uint32 addr) -> uint8 {
|
2010-08-09 13:28:56 +00:00
|
|
|
if(regs.e && regs.d.l == 0x00) {
|
2016-03-26 01:56:15 +00:00
|
|
|
return read((regs.d & 0xff00) + ((regs.d + (addr & 0xffff)) & 0xff));
|
2010-08-09 13:28:56 +00:00
|
|
|
} else {
|
2016-03-26 01:56:15 +00:00
|
|
|
return read((regs.d + (addr & 0xffff)) & 0xffff);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto readsp(uint32 addr) -> uint8 {
|
|
|
|
return read((regs.s + (addr & 0xffff)) & 0xffff);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto writestack(uint8 data) -> void {
|
|
|
|
write(regs.s.w, data);
|
2010-08-09 13:28:56 +00:00
|
|
|
regs.e ? regs.s.l-- : regs.s.w--;
|
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto writestackn(uint8 data) -> void {
|
|
|
|
write(regs.s.w--, data);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto writeaddr(uint32 addr, uint8 data) -> void {
|
|
|
|
write(addr & 0xffff, data);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto writelong(uint32 addr, uint8 data) -> void {
|
|
|
|
write(addr & 0xffffff, data);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto writedbr(uint32 addr, uint8 data) -> void {
|
|
|
|
write(((regs.db << 16) + addr) & 0xffffff, data);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto writepbr(uint32 addr, uint8 data) -> void {
|
|
|
|
write((regs.pc.b << 16) + (addr & 0xffff), data);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto writedp(uint32 addr, uint8 data) -> void {
|
2010-08-09 13:28:56 +00:00
|
|
|
if(regs.e && regs.d.l == 0x00) {
|
2016-03-26 01:56:15 +00:00
|
|
|
write((regs.d & 0xff00) + ((regs.d + (addr & 0xffff)) & 0xff), data);
|
2010-08-09 13:28:56 +00:00
|
|
|
} else {
|
2016-03-26 01:56:15 +00:00
|
|
|
write((regs.d + (addr & 0xffff)) & 0xffff, data);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-26 01:56:15 +00:00
|
|
|
alwaysinline auto writesp(uint32 addr, uint8 data) -> void {
|
|
|
|
write((regs.s + (addr & 0xffff)) & 0xffff, data);
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|