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

All times are UTC




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Memory map
PostPosted: Fri Aug 17, 2018 10:02 am 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Hi guys

I've recently returned to my 65C02 cross emulator (6502CA) which I've been writing for what feels like forever :D.
Much of it is done functionality wise, but with a few exceptions. Once of which is the implementation of a basic memory map facility usable by the Simulator part of the project.
The basic RAM/ROM side of things will be easy to implement, but I was wondering about basic VIA/ACIA implemetation and whether it's worth adding this in or just have a generic "I/O" classification.
If do try going beyond simple "I/O" then should I just have registers - at which ppint might as well be RAM - or should I try adding in (for the VIA) timers and maybe basic IRQ vector calling and have the port A and B have a window which you can toggle the lines on? Is it worth the effort?
Timers might be not worth it as the Simulator is not an Emulator and so, although it keeps track fo cycles, does not adhere to any time specifications and takes as long as it takes to execute a given instruction.


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Fri Aug 17, 2018 12:01 pm 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
You could tie an ACIA emulation to console input and output, which would make your emulator much more useful than a pure RAM/ROM model. That's probably the first thing I'd do.

The next most useful thing would be the VIA's timers, which you can use to give your emulated machine a sense of time independent of its instruction execution rate. Feed your virtual VIA with a 1MHz clock on one timer and a 32kHz clock on the other, or something similar. Or skip the VIA (it's actually quite tricky to emulate *correctly*) and implement some simple RTC chip.


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Fri Aug 17, 2018 4:08 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Yep, I'd certainly go for the ACIA next - really just a byte to read and a byte to write, no need to model control register and you can probably even get away without modelling the status register.

After that, a byte-wide In port and a byte-wide Out port might be good, if your emulation is suited to emulating a bank of LEDs and a bank of switches. That's the very basics of a PIA.

And then, yes, modelling some kind of timer might be good. Perhaps not trying to match the VIA behaviour precisely, but something good enough to set up a heartbeat interrupt.


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Fri Aug 17, 2018 5:04 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
In that case I'll give it a go. Down side is that I'll need to write in an abstraction layer for ram access for intercepting read/writes not destined for RAM, but as speed isn't a huge issue it should be ok.

EDIT: Also will have to add in an an IRQ system, Timers, line interface. Should be fun!


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Fri Aug 17, 2018 8:44 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
Depends on your goals.

For mine, I simply have "magic" addresses. For example, I have an address that returns 0 or 1 if a key is ready, and another that returns the key value. Similarly, if I write to an address, a character appears on the display.

I also have a set of contrived disk operations to read and write blocks from the "disk".

These don't mimic any known hardware. But they're perfectly adequate so far for writing 6502 software.

So, if you just want character I/O, do character I/O. if you want to mimic hardware, throw interrupts, and such -- then do that.

Mind, my system just interprets instructions, it doesn't do cycle by cycle processing, doesn't mimic lines from the chip to the pins to the bus, or anything like that. It's simply a 6502 interpreter. When you start mimicking hardware, that may or may not be enough, depends on how far you want to go.


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Fri Aug 17, 2018 11:04 pm 
Offline
User avatar

Joined: Sun Sep 08, 2013 10:24 am
Posts: 740
Location: A missile silo somewhere under southern England
Not got that (yet) for input, but I do have something similar output-wise. I have simulator options which cause JSRs to specified addresses to be intercepted and display things in the assembler output window. Here's a screen shot. Got to admit the descriptive text needs a bit of work (as does the layout - all being rearranged atm), but I hope you get the gist. These special modes can be enabled by command in the source code as well as in the GUI:
Syntax:
SimOptText <mode> <status> <intercept address>
E.g.
SimOptText 4 Enable $FFEE

Attachment:
SimulatorOptions.gif
SimulatorOptions.gif [ 121.82 KiB | Viewed 4410 times ]


With regards the I/O mapping:

I think having this would be handy for trying basic I/O stuff so am proceeding with VIAs and will then look at ACIAs.

So far I've built some structures for up to 4 VIAs, adding in an abstraction layer for RAM read and writes so I can intercept stuff forIO, ROM, etc and have implemented partial access to VIA registers.
No GUI, timer, etc. stuff for VIA interaction and still got to do the IRQ stuff. Getting there.


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Thu Aug 30, 2018 8:10 pm 
Offline

Joined: Tue Feb 24, 2015 11:07 pm
Posts: 81
Chromatix wrote:
You could tie an ACIA emulation to console input and output, which would make your emulator much more useful than a pure RAM/ROM model. That's probably the first thing I'd do.

I did this for my CoffeeScript-based emulator. From the command-line I can now invoke the emulator, passing a .prg file and it starts up and interacts via the console. I had to implement support for IRQs because the ACIA code in my monitor uses them.

Although the emulator only emulates at the instruction rather than cycle level, I found it much easier to emulate the memory map "properly" with an emulated address decoder and an API that a bus device implements because it simplified the decision-making process. Having to make decisions slows me down.


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Thu Aug 30, 2018 8:30 pm 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
whartung wrote:
For mine, I simply have "magic" addresses. For example, I have an address that returns 0 or 1 if a key is ready, and another that returns the key value. Similarly, if I write to an address, a character appears on the display.

I would have it return 0 or 255, that way it can be tested with the BIT instruction.


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Thu Aug 30, 2018 8:32 pm 
Offline

Joined: Thu Feb 10, 2011 3:14 am
Posts: 79
I like the idea of emulating VIAs, since nearly every physiical 6502 based system used some variation of them.


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Fri Aug 31, 2018 4:46 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
banedon wrote:
I've recently returned to my 65C02 cross emulator (6502CA) which I've been writing for what feels like forever :D.

A pedantic note: what you are creating is a simulator, not an emulator. Emulation implies the use of a specific type of hardware that is capable of being made to faithfully act like the actual 65C02.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Fri Aug 31, 2018 5:09 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
BigDumbDinosaur wrote:
banedon wrote:
I've recently returned to my 65C02 cross emulator (6502CA) which I've been writing for what feels like forever :D.

A pedantic note: what you are creating is a simulator, not an emulator. Emulation implies the use of a specific type of hardware that is capable of being made to faithfully act like the actual 65C02.

Our discussion on that is in the topic "Terminology: Simulator vs. Emulator." (I agree with BDD.)

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Fri Aug 31, 2018 5:31 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
And there the discussion should stay, ideally. "Pedantic" is a confession, as much as a description.


Top
 Profile  
Reply with quote  
 Post subject: Re: Memory map
PostPosted: Fri Aug 31, 2018 5:44 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8514
Location: Midwestern USA
BigEd wrote:
And there the discussion should stay, ideally. "Pedantic" is a confession, as much as a description.

:D :lol: :D

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 76 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: