6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 8:13 am

All times are UTC




Post new topic Reply to topic  [ 57 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Mon Jun 12, 2017 3:35 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
bluesky6 wrote:
@Daryl, I've used your monitor "lite" codebase to build a simple monitor for the RC2014 6502 board. While I've reused a number of the subroutines, I've changed the user interface a fair bit to produce that same/similar behavior as my Z80 monitor for the RC2014. I've also added a (C) continue command to the BRK handler so that you can actually continue program execution after examining the registers. This is a little simpler than what I implemented for the Z80; primarily because there's essentially only one stack on the 6502. Whereas the Z80 can have a Monitor stack and an application one. So you can hit a breakpoint, go out to the full Monitor, and look at/change memory contents... (Note: not intending to start a CPU religious war here. We know who won: it starts with A :lol: ).


The C command is a great idea. I built the BRK handler with the intention of using it for debugging. I would overwrite an opcode with BRK to verify expected vs. actual register & flag contents. But I usually just replaced the BRK with the original code, moved the BRK to another test location, and reran from the start. Having the ability to continue is an added feature, but best used with BRK's included into the source.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 12, 2017 4:38 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
bluesky6 wrote:
(Note: not intending to start a CPU religious war here. We know who won: it starts with A :lol: ).

A?

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


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 7:29 am 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
.. followed by 'RM', I guess.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 7:31 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
Tor wrote:
.. followed by 'RM', I guess.

...or followed with MD. :D

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


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 1:59 pm 
Offline

Joined: Mon Jan 09, 2017 3:50 pm
Posts: 39
@Daryl, we tend to build tools that fit our individual SOPs. I tended to populate my code with printfs (back in the day), so populating it with BRK is just an extension of that :)

The 6502 implementation here is a little less flexible than the Z80 one. With the latter, you can jump back to the monitor, use the memory examine command to modify the stored register values, then hit C to continue execution i.e. do some what-ifs.

So who won the CPU architecture wars? Yes, it's ARM :)

_________________
Blog: http://ancientcomputing.blogspot.com/
GitHub: https://github.com/ancientcomputing


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 5:17 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
bluesky6 wrote:
The 6502 implementation here is a little less flexible than the Z80 one. With the latter, you can jump back to the monitor, use the memory examine command to modify the stored register values, then hit C to continue execution i.e. do some what-ifs.

Any well-designed 6502 monitor will implement similar functionality. For example, in Supermon64, if a program was interrupted with BRK it can be resumed with the G (run program) command, which will reload the context that existed when BRK was encountered. It has nothing to do with the MPU and everything to do with the programmer.

Quote:
So who won the CPU architecture wars? Yes, it's ARM :)

I didn't know MPUs were at war with each other.

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


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 5:19 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
bluesky6 wrote:
not intending to start a CPU religious war here. ... :lol: ).

Unfortunately, as you've seen, there are some topics here which it is impossible to mention, even in jest, without getting a "discussion" about them which detracts from the conversation.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 6:57 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
It would be interesting to see a couple of stock FIG Forths going head to head on the Z80 and 6502. Out of the box, they should both be "reasonable" implementations (in terms of efficiency), the architecture should be pretty much identical, and the benchmark can be written in high level Forth and ported, much like the BASIC.

Wouldn't be perfect, by no means, as a Forth probably tests only a specific subset of the CPUs capability, but at least in terms of "cycle to cycle" performance for "similar tasks", I think a FIG Forth would have less margin for disparity.

But then, you're probably, in the end, just testing NEXT, FETCH, STORE, stack handling, and some basic math primitives.

Still, might be enlightening.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 13, 2017 8:33 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
whartung wrote:
It would be interesting to see a couple of stock FIG Forths going head to head on the Z80 and 6502. Out of the box, they should both be "reasonable" implementations (in terms of efficiency), the architecture should be pretty much identical, and the benchmark can be written in high level Forth and ported, much like the BASIC ...

I can tell you from personal experience with MS BASIC (on the TRS-80 M1 L2 and the early PET and Apple ][) that the perceived difference was quite noticeably in favor of the 65xxers, even with 32-bit floats on the former (by default) vs. 40-bit floats on the latter two.

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 14, 2017 1:29 pm 
Offline

Joined: Mon Jan 09, 2017 3:50 pm
Posts: 39
So back to my question: I'd like to strip out the NMI/IRQ code.

Are there dependencies (beyond the CTRL-C handler) that will result in a less stable EhBASIC?

_________________
Blog: http://ancientcomputing.blogspot.com/
GitHub: https://github.com/ancientcomputing


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 15, 2017 5:36 am 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
As far as I can tell from my experience in modifying the interrupt system in EHBasic there are no "deep roots" of the interrupt handler in EHBasic. Just keep in mind that if you remove or change EHBasic keywords, a binary SAVE / LOAD will not be compatible across EHBasic versions.

_________________
6502 sources on GitHub: https://github.com/Klaus2m5


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 01, 2017 11:26 pm 
Offline

Joined: Mon Jan 09, 2017 3:50 pm
Posts: 39
I took advantage of the long July 4th weekend over here to check out things and improve the overall EhBASIC experience using the 6502 CPU Board for the RC2014.

The first thing I realized was that I'd failed to check into GitHub the latest code. Done: https://github.com/ancientcomputing/rc2014/tree/master/source/6502/ehbasic

The second thing I did was to enable the UART receive interrupt (on the 16C550) with characters dumping into a 63-byte buffer and then implement manual RTS handling according to pre-defined low and high water marks.

While doing this I realized that EhBASIC is really crappy with zero page usage. It was basically clobbering my buffer pointers. I didn't want to cannibalize the zero page locations that the Monitor/Debugger was using since the UART buffer will be used by the Monitor (monitor commands and Intel Hex uploads). So I ended up moving the buffer pointers to Page 3. The code ends up being relatively inefficient (absolute addressing etc) and longer but it seems to work...

The resulting Monitor/Debugger + EhBASIC is in GitHub here: https://github.com/ancientcomputing/rc2014/blob/master/rom/6502/monitor_ehbasic/monbas65_16C550_irq.rom

The upside of the use of the interrupt driven and buffer-backed serial input is the following:
I now can run a 1MHz 6502 at 115200 baud with no errors with Intel Hex uploads with the Monitor or BASIC source code uploads with both EhBASIC and MS BASIC.

Previously, I had to configure my terminal emulator to use character delays.

_________________
Blog: http://ancientcomputing.blogspot.com/
GitHub: https://github.com/ancientcomputing


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 02, 2017 12:36 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
bluesky6 wrote:
... While doing this I realized that EhBASIC is really crappy with zero page usage. It was basically clobbering my buffer pointers ...


"Crappy" might be a bit harsh ... maybe "greedy"? Who was there first, anyway? :wink:

A clash over 65xx zero-page real-estate is certainly not without ample precedent. When you try make two or more non-trivial applications play well with each other in 65xx land, you have to keep a very close eye on their zero-page usage or you will wind up with some nasty bugs (some of which may be very intermittent). Of course, you already knew that, or at least you do now!

Mike B.


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 02, 2017 4:04 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
bluesky6 wrote:
While doing this I realized that EhBASIC is really crappy with zero page usage.

It all depends on how you define "crappy." The Commodore 64 used virtually all of zero page for BASIC and the kernel, leading only five or six zero page locations that were guaranteed to not be disturbed.

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


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 02, 2017 6:59 am 
Offline

Joined: Sat Jul 28, 2012 11:41 am
Posts: 442
Location: Wiesbaden, Germany
bluesky6 wrote:
The upside of the use of the interrupt driven and buffer-backed serial input is the following:
I now can run a 1MHz 6502 at 115200 baud with no errors with Intel Hex uploads with the Monitor or BASIC source code uploads with both EhBASIC and MS BASIC.

What? You are using a 1 MHz CPU with 115200 baud? :shock: :shock: :shock:

Let me do the math for you. 115200 baud means a character every 10 bits, so 11520 chars/s. The CPU has one million cycles per second. So there is 86.8 cycles per character.

In this 86.8 cycles you want to interrupt for each character and stuff it into a buffer. Then Ehbasic comes along and fetches the character from the buffer and needs to do something usefull with it while there are more characters coming in.

I hope you see, what is going wrong here. Of course EhBASIC was never meant to deal with massive program uploads like that. It is fast enough to catch what you type on a terminal though, even at 115200 baud. LOAD & SAVE was meant to be binary just stuffing memory sequentially and not having to tokenize every line and stuffing it into the middle of an existing frame (NEW helps in that case).

_________________
6502 sources on GitHub: https://github.com/Klaus2m5


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 57 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC


Who is online

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