- Fixed CMP

- Fixed SBC
- Fixed RAM access from Swift
This commit is contained in:
Tamas Rudnai 2019-09-08 14:52:52 -07:00
parent c907317419
commit b9e8640178
4 changed files with 12 additions and 12 deletions

View File

@ -13,9 +13,13 @@ class ViewController: NSViewController {
@IBOutlet weak var display: NSTextFieldCell!
func check() {
let ram = UnsafeRawBufferPointer(start: &RAM+0x400, count: 0x400)
let string = String(bytes: ram, encoding: .utf8)
print(string)
let textBufferPointer = UnsafeRawBufferPointer(start: &RAM+0x400, count: 0x400)
// let string = String(bytes: ram, encoding: .utf8)
// print(string)
for (index, byte) in textBufferPointer.enumerated() {
print("byte \(index): \(byte)")
}
}
@ -63,9 +67,9 @@ class ViewController: NSViewController {
// }
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0, execute: {
self.check()
})
// DispatchQueue.main.asyncAfter(deadline: .now() + 5.0, execute: {
// self.check()
// })
}

View File

@ -65,7 +65,7 @@ static inline void set_flags_NVZ( uint8_t test ) {
static inline void set_flags_NZC( int test ) {
set_flags_NZ(test);
m6502.flags.C = (unsigned)test > 0xFF;
m6502.flags.C = test >= 0;
}
static inline void set_flags_NZCV( int test ) {

View File

@ -53,10 +53,7 @@ static inline void ADC( uint8_t imm ) {
(indirect),Y SBC (oper),Y F1 2 5*
**/
static inline void SBC( uint8_t imm ) {
int tmp = (int)m6502.A - imm - m6502.flags.C;
dbgPrintf("SBC A:%02X - i:%02X - C:%u = %02X", m6502.A, imm, m6502.flags.C, tmp);
m6502.A = (uint8_t)tmp;
set_flags_NZCV( tmp );
ADC( ~imm );
}
#endif // __6502_INSTR_ARITHMETIC_H__

View File

@ -93,7 +93,6 @@ static inline void STR( uint8_t * dst, uint8_t imm ) {
*dst = imm;
// uint16_t v = dst - RAM;
// if ( ( v >= 0x400 ) && ( v < 0x800 ) ) {
// char c = charConv[imm];
// if (( imm > ' ' ) && ( c < 0x7F ))