summaryrefslogtreecommitdiffstats
path: root/src/devices/cpu/m6502/m6502.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/m6502/m6502.cpp')
-rw-r--r--src/devices/cpu/m6502/m6502.cpp128
1 files changed, 64 insertions, 64 deletions
diff --git a/src/devices/cpu/m6502/m6502.cpp b/src/devices/cpu/m6502/m6502.cpp
index 6fa76704731..1194273fae3 100644
--- a/src/devices/cpu/m6502/m6502.cpp
+++ b/src/devices/cpu/m6502/m6502.cpp
@@ -14,7 +14,7 @@
const device_type M6502 = &device_creator<m6502_device>;
-m6502_device::m6502_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
+m6502_device::m6502_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
cpu_device(mconfig, M6502, "M6502", tag, owner, clock, "m6502", __FILE__),
sync_w(*this),
program_config("program", ENDIANNESS_LITTLE, 8, 16),
@@ -24,7 +24,7 @@ m6502_device::m6502_device(const machine_config &mconfig, const char *tag, devic
direct_disabled = false;
}
-m6502_device::m6502_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) :
+m6502_device::m6502_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source) :
cpu_device(mconfig, type, name, tag, owner, clock, shortname, source),
sync_w(*this),
program_config("program", ENDIANNESS_LITTLE, 8, 16),
@@ -126,30 +126,30 @@ void m6502_device::device_reset()
}
-UINT32 m6502_device::execute_min_cycles() const
+uint32_t m6502_device::execute_min_cycles() const
{
return 1;
}
-UINT32 m6502_device::execute_max_cycles() const
+uint32_t m6502_device::execute_max_cycles() const
{
return 10;
}
-UINT32 m6502_device::execute_input_lines() const
+uint32_t m6502_device::execute_input_lines() const
{
return NMI_LINE+1;
}
-void m6502_device::do_adc_d(UINT8 val)
+void m6502_device::do_adc_d(uint8_t val)
{
- UINT8 c = P & F_C ? 1 : 0;
+ uint8_t c = P & F_C ? 1 : 0;
P &= ~(F_N|F_V|F_Z|F_C);
- UINT8 al = (A & 15) + (val & 15) + c;
+ uint8_t al = (A & 15) + (val & 15) + c;
if(al > 9)
al += 6;
- UINT8 ah = (A >> 4) + (val >> 4) + (al > 15);
- if(!UINT8(A + val + c))
+ uint8_t ah = (A >> 4) + (val >> 4) + (al > 15);
+ if(!uint8_t(A + val + c))
P |= F_Z;
else if(ah & 8)
P |= F_N;
@@ -162,14 +162,14 @@ void m6502_device::do_adc_d(UINT8 val)
A = (ah << 4) | (al & 15);
}
-void m6502_device::do_adc_nd(UINT8 val)
+void m6502_device::do_adc_nd(uint8_t val)
{
- UINT16 sum;
+ uint16_t sum;
sum = A + val + (P & F_C ? 1 : 0);
P &= ~(F_N|F_V|F_Z|F_C);
- if(!UINT8(sum))
+ if(!uint8_t(sum))
P |= F_Z;
- else if(INT8(sum) < 0)
+ else if(int8_t(sum) < 0)
P |= F_N;
if(~(A^val) & (A^sum) & 0x80)
P |= F_V;
@@ -178,7 +178,7 @@ void m6502_device::do_adc_nd(UINT8 val)
A = sum;
}
-void m6502_device::do_adc(UINT8 val)
+void m6502_device::do_adc(uint8_t val)
{
if(P & F_D)
do_adc_d(val);
@@ -195,7 +195,7 @@ void m6502_device::do_arr_nd()
A |= 0x80;
if(!A)
P |= F_Z;
- else if(INT8(A)<0)
+ else if(int8_t(A)<0)
P |= F_N;
if(A & 0x40)
P |= F_V|F_C;
@@ -208,12 +208,12 @@ void m6502_device::do_arr_d()
// The adc/ror interaction gives an extremely weird result
bool c = P & F_C;
P &= ~(F_N|F_Z|F_C|F_V);
- UINT8 a = A >> 1;
+ uint8_t a = A >> 1;
if(c)
a |= 0x80;
if(!a)
P |= F_Z;
- else if(INT8(a) < 0)
+ else if(int8_t(a) < 0)
P |= F_N;
if((a ^ A) & 0x40)
P |= F_V;
@@ -236,28 +236,28 @@ void m6502_device::do_arr()
do_arr_nd();
}
-void m6502_device::do_cmp(UINT8 val1, UINT8 val2)
+void m6502_device::do_cmp(uint8_t val1, uint8_t val2)
{
P &= ~(F_N|F_Z|F_C);
- UINT16 r = val1-val2;
+ uint16_t r = val1-val2;
if(!r)
P |= F_Z;
- else if(INT8(r) < 0)
+ else if(int8_t(r) < 0)
P |= F_N;
if(!(r & 0xff00))
P |= F_C;
}
-void m6502_device::do_sbc_d(UINT8 val)
+void m6502_device::do_sbc_d(uint8_t val)
{
- UINT8 c = P & F_C ? 0 : 1;
+ uint8_t c = P & F_C ? 0 : 1;
P &= ~(F_N|F_V|F_Z|F_C);
- UINT16 diff = A - val - c;
- UINT8 al = (A & 15) - (val & 15) - c;
- if(INT8(al) < 0)
+ uint16_t diff = A - val - c;
+ uint8_t al = (A & 15) - (val & 15) - c;
+ if(int8_t(al) < 0)
al -= 6;
- UINT8 ah = (A >> 4) - (val >> 4) - (INT8(al) < 0);
- if(!UINT8(diff))
+ uint8_t ah = (A >> 4) - (val >> 4) - (int8_t(al) < 0);
+ if(!uint8_t(diff))
P |= F_Z;
else if(diff & 0x80)
P |= F_N;
@@ -265,18 +265,18 @@ void m6502_device::do_sbc_d(UINT8 val)
P |= F_V;
if(!(diff & 0xff00))
P |= F_C;
- if(INT8(ah) < 0)
+ if(int8_t(ah) < 0)
ah -= 6;
A = (ah << 4) | (al & 15);
}
-void m6502_device::do_sbc_nd(UINT8 val)
+void m6502_device::do_sbc_nd(uint8_t val)
{
- UINT16 diff = A - val - (P & F_C ? 0 : 1);
+ uint16_t diff = A - val - (P & F_C ? 0 : 1);
P &= ~(F_N|F_V|F_Z|F_C);
- if(!UINT8(diff))
+ if(!uint8_t(diff))
P |= F_Z;
- else if(INT8(diff) < 0)
+ else if(int8_t(diff) < 0)
P |= F_N;
if((A^val) & (A^diff) & 0x80)
P |= F_V;
@@ -285,7 +285,7 @@ void m6502_device::do_sbc_nd(UINT8 val)
A = diff;
}
-void m6502_device::do_sbc(UINT8 val)
+void m6502_device::do_sbc(uint8_t val)
{
if(P & F_D)
do_sbc_d(val);
@@ -293,10 +293,10 @@ void m6502_device::do_sbc(UINT8 val)
do_sbc_nd(val);
}
-void m6502_device::do_bit(UINT8 val)
+void m6502_device::do_bit(uint8_t val)
{
P &= ~(F_N|F_Z|F_V);
- UINT8 r = A & val;
+ uint8_t r = A & val;
if(!r)
P |= F_Z;
if(val & 0x80)
@@ -305,20 +305,20 @@ void m6502_device::do_bit(UINT8 val)
P |= F_V;
}
-UINT8 m6502_device::do_asl(UINT8 v)
+uint8_t m6502_device::do_asl(uint8_t v)
{
P &= ~(F_N|F_Z|F_C);
- UINT8 r = v<<1;
+ uint8_t r = v<<1;
if(!r)
P |= F_Z;
- else if(INT8(r) < 0)
+ else if(int8_t(r) < 0)
P |= F_N;
if(v & 0x80)
P |= F_C;
return r;
}
-UINT8 m6502_device::do_lsr(UINT8 v)
+uint8_t m6502_device::do_lsr(uint8_t v)
{
P &= ~(F_N|F_Z|F_C);
if(v & 1)
@@ -329,7 +329,7 @@ UINT8 m6502_device::do_lsr(UINT8 v)
return v;
}
-UINT8 m6502_device::do_ror(UINT8 v)
+uint8_t m6502_device::do_ror(uint8_t v)
{
bool c = P & F_C;
P &= ~(F_N|F_Z|F_C);
@@ -340,12 +340,12 @@ UINT8 m6502_device::do_ror(UINT8 v)
v |= 0x80;
if(!v)
P |= F_Z;
- else if(INT8(v)<0)
+ else if(int8_t(v)<0)
P |= F_N;
return v;
}
-UINT8 m6502_device::do_rol(UINT8 v)
+uint8_t m6502_device::do_rol(uint8_t v)
{
bool c = P & F_C;
P &= ~(F_N|F_Z|F_C);
@@ -356,12 +356,12 @@ UINT8 m6502_device::do_rol(UINT8 v)
v |= 0x01;
if(!v)
P |= F_Z;
- else if(INT8(v)<0)
+ else if(int8_t(v)<0)
P |= F_N;
return v;
}
-UINT8 m6502_device::do_asr(UINT8 v)
+uint8_t m6502_device::do_asr(uint8_t v)
{
P &= ~(F_N|F_Z|F_C);
if(v & 1)
@@ -456,20 +456,20 @@ void m6502_device::state_string_export(const device_state_entry &entry, std::str
}
-UINT32 m6502_device::disasm_min_opcode_bytes() const
+uint32_t m6502_device::disasm_min_opcode_bytes() const
{
return 1;
}
-UINT32 m6502_device::disasm_max_opcode_bytes() const
+uint32_t m6502_device::disasm_max_opcode_bytes() const
{
return 4;
}
-offs_t m6502_device::disassemble_generic(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options, const disasm_entry *table)
+offs_t m6502_device::disassemble_generic(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *table)
{
const disasm_entry &e = table[oprom[0] | inst_state_base];
- UINT32 flags = e.flags | DASMFLAG_SUPPORTED;
+ uint32_t flags = e.flags | DASMFLAG_SUPPORTED;
buffer += sprintf(buffer, "%s", e.opcode);
switch(e.mode) {
@@ -557,17 +557,17 @@ offs_t m6502_device::disassemble_generic(char *buffer, offs_t pc, const UINT8 *o
break;
case DASM_rel:
- sprintf(buffer, " $%04x", (pc & 0xf0000) | UINT16(pc + 2 + INT8(opram[1])));
+ sprintf(buffer, " $%04x", (pc & 0xf0000) | uint16_t(pc + 2 + int8_t(opram[1])));
flags |= 2;
break;
case DASM_rw2:
- sprintf(buffer, " $%04x", (pc & 0xf0000) | UINT16(pc + 2 + INT16((opram[2] << 8) | opram[1])));
+ sprintf(buffer, " $%04x", (pc & 0xf0000) | uint16_t(pc + 2 + int16_t((opram[2] << 8) | opram[1])));
flags |= 3;
break;
case DASM_zpb:
- sprintf(buffer, "%d $%02x, $%04x", (oprom[0] >> 4) & 7, opram[1], (pc & 0xf0000) | UINT16(pc + 3 + INT8(opram[2])));
+ sprintf(buffer, "%d $%02x, $%04x", (oprom[0] >> 4) & 7, opram[1], (pc & 0xf0000) | uint16_t(pc + 3 + int8_t(opram[2])));
flags |= 3;
break;
@@ -607,12 +607,12 @@ offs_t m6502_device::disassemble_generic(char *buffer, offs_t pc, const UINT8 *o
break;
case DASM_bzr:
- sprintf(buffer, " %d, $%02x, $%04x", (opram[0] >> 5) & 7, opram[1], (pc & 0xf0000) | UINT16(pc + 3 + INT8(opram[2])));
+ sprintf(buffer, " %d, $%02x, $%04x", (opram[0] >> 5) & 7, opram[1], (pc & 0xf0000) | uint16_t(pc + 3 + int8_t(opram[2])));
flags |= 3;
break;
case DASM_bar:
- sprintf(buffer, " %d, a, $%04x", (opram[0] >> 5) & 7, (pc & 0xf0000) | UINT16(pc + 3 + INT8(opram[1])));
+ sprintf(buffer, " %d, a, $%04x", (opram[0] >> 5) & 7, (pc & 0xf0000) | uint16_t(pc + 3 + int8_t(opram[1])));
flags |= 2;
break;
@@ -655,7 +655,7 @@ void m6502_device::prefetch_noirq()
PC++;
}
-void m6502_device::set_nz(UINT8 v)
+void m6502_device::set_nz(uint8_t v)
{
P &= ~(F_Z|F_N);
if(v & 0x80)
@@ -664,50 +664,50 @@ void m6502_device::set_nz(UINT8 v)
P |= F_Z;
}
-offs_t m6502_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
+offs_t m6502_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
{
return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries);
}
-UINT8 m6502_device::memory_interface::read_9(UINT16 adr)
+uint8_t m6502_device::memory_interface::read_9(uint16_t adr)
{
return read(adr);
}
-void m6502_device::memory_interface::write_9(UINT16 adr, UINT8 val)
+void m6502_device::memory_interface::write_9(uint16_t adr, uint8_t val)
{
write(adr, val);
}
-UINT8 m6502_device::mi_default_normal::read(UINT16 adr)
+uint8_t m6502_device::mi_default_normal::read(uint16_t adr)
{
return program->read_byte(adr);
}
-UINT8 m6502_device::mi_default_normal::read_sync(UINT16 adr)
+uint8_t m6502_device::mi_default_normal::read_sync(uint16_t adr)
{
return sdirect->read_byte(adr);
}
-UINT8 m6502_device::mi_default_normal::read_arg(UINT16 adr)
+uint8_t m6502_device::mi_default_normal::read_arg(uint16_t adr)
{
return direct->read_byte(adr);
}
-void m6502_device::mi_default_normal::write(UINT16 adr, UINT8 val)
+void m6502_device::mi_default_normal::write(uint16_t adr, uint8_t val)
{
program->write_byte(adr, val);
}
-UINT8 m6502_device::mi_default_nd::read_sync(UINT16 adr)
+uint8_t m6502_device::mi_default_nd::read_sync(uint16_t adr)
{
return sprogram->read_byte(adr);
}
-UINT8 m6502_device::mi_default_nd::read_arg(UINT16 adr)
+uint8_t m6502_device::mi_default_nd::read_arg(uint16_t adr)
{
return program->read_byte(adr);
}