Hi guys,
I am happy to share my last project with you.
I was inspired of 6502 emulation challenge here.
I got this code and ported it for AVR. In fact only read and write functions are target dependable.
Then I got the .bin file for EhBasic.
Then I got a 23LCV1024-I/P SPI RAM and 25LC256-I/P SPI EEPROM .
Put all together and it worked.
Later I put SD card module. Now this PC can boot from SD card. Just copy the ROM file the SD card.
Before that I was build this Video/KBD interface.
AVR/6502 instruction ratio is about 600 (having ROM data in FLASH).
AVR is running on 18,432 MHz. That makes about 30 KHz emulated speed.
Having ROM data in external EEPROM ratio is about 1500.
Here are some pictures.
AVR6502
AVR6502
- Attachments
-
- 20131228_sd_card.zip
- Last version (still draft). SD card APIs (ELM CHAN's FatFS) included. Now It can boot from SD card.
- (378.19 KiB) Downloaded 214 times
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: AVR6502
I think that there might be a bug in Mike Chambers' BCD adjustment inside adc():
I believe that it always produces a BCD result, but ignores the half-carry, and will produce the wrong result for something as simple as 9+9 (if I'm reading the code properly, it looks like it will give an answer of $12, regardless of mode). I don't have my compiler handy at the moment, but I think that I'm right.
What do you guys think would be the most efficient method to include the half-carry, especially for an eight-digit version of the same function? I don't consider myself to be a C expert, but it appears to be a bit weak in its handling of carries and half-carries. I know that it can be done, just not very efficiently, at least be me.
BTW, could you share the code that you used to implement the read6502 and write6502 external functions?
Thanks,
Mike
Code: Select all
//instruction handler functions
static void adc() {
penaltyop = 1;
value = getvalue();
result = (uint16_t)a + value + (uint16_t)(status & FLAG_CARRY);
carrycalc(result);
zerocalc(result);
overflowcalc(result, a, value);
signcalc(result);
#ifndef NES_CPU
if (status & FLAG_DECIMAL) {
clearcarry();
if ((a & 0x0F) > 0x09) {
a += 0x06;
}
if ((a & 0xF0) > 0x90) {
a += 0x60;
setcarry();
}
clockticks6502++;
}
#endif
saveaccum(result);
}
What do you guys think would be the most efficient method to include the half-carry, especially for an eight-digit version of the same function? I don't consider myself to be a C expert, but it appears to be a bit weak in its handling of carries and half-carries. I know that it can be done, just not very efficiently, at least be me.
BTW, could you share the code that you used to implement the read6502 and write6502 external functions?
Thanks,
Mike
Re: AVR6502
(I started a new thread for discussion of wide BCD - see viewtopic.php?f=10&t=2841&p=31421#p31421 )
Edit: I should have said that I'd meant the new thread to be about hardware, and leave this thread to continue on software... but I didn't [oops], so now it's worth looking to the new thread for both hardware and software aspects of BCD. Sorry for confusion.
Cheers
Ed
Edit: I should have said that I'd meant the new thread to be about hardware, and leave this thread to continue on software... but I didn't [oops], so now it's worth looking to the new thread for both hardware and software aspects of BCD. Sorry for confusion.
Cheers
Ed