6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 10:58 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: AVR6502
PostPosted: Tue Dec 31, 2013 5:42 pm 
Offline

Joined: Mon Dec 09, 2013 8:52 pm
Posts: 3
Location: Sofia, Bulgaria
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.
ImageImageImageImage


Attachments:
File comment: Last version (still draft). SD card APIs (ELM CHAN's FatFS) included. Now It can boot from SD card.
20131228_sd_card.zip [378.19 KiB]
Downloaded 183 times
Top
 Profile  
Reply with quote  
 Post subject: Re: AVR6502
PostPosted: Sun Jan 12, 2014 7:31 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1952
Location: Sacramento, CA, USA
I think that there might be a bug in Mike Chambers' BCD adjustment inside adc():

Code:
//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);
}


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


Top
 Profile  
Reply with quote  
 Post subject: Re: AVR6502
PostPosted: Sun Jan 12, 2014 8:02 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
(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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: